今天试试看使用手机调用相册,获取里面的图片或视频资源,特么崩了。然后看到控制台输出了以下信息:
This app has crashed because it attempted to access privacy-sensitive
data without a usage description. The app's Info.plist must contain an NSPhotoLibraryUsageDescription key with a string value explaining to the user how the app uses this data.
接着百度一下,找到了解答方案。
1.在项目中找到info.plist
文件,右键点击以 Source
Code
形式打开
2.添加以下键值对,这里以 PhotoLibrary 作为例子
<key>NSPhotoLibraryUsageDescription</key>
<string>App需要您的同意,才能访问相册</string>
<key>NSCameraUsageDescription</key>
<string>App需要您的同意,才能访问相机</string>