今天测试一个Unity3D的项目,在调用相机时候崩溃,原因是由于iOS10,增加了访问的权限,所以导致Crash。
- 控制台输出的错误日志
This app has crashed because it attempted to access privacy-sensitive data without a usage description. The app's Info.plist must contain an NSContactsUsageDescription key with a string value explaining to the user how the app uses this data.
然后就解决呗,在info.plist中加入相册和相机使用描述字段即可.
- 方法1 右键点击info.plist选择open as->source code,将下面的字段加入
<key>NSCameraUsageDescription</key>
<string>这里写app使用相机时的描述~~</string>
<key>NSPhotoLibraryUsageDescription</key>
<string>这里写app使用相册时的描述~~</string>
- 方法2 如下图