ionic-framework - Ionic 3 相机插件在 iPhone 上因 saveToPhotoAlbum true 而崩溃
问题描述
我正在使用 Ionic 3,我正在尝试拍照并将其直接保存到图库中。
它在 Android 上运行良好,但在 iPhone 上崩溃,当我将 saveToPhotoAlbum 设置为 false 时,它运行良好,所以我意识到问题出在这个选项上。
我正在使用文档代码:
home.ts:
const options: CameraOptions = {
quality: 100,
sourceType: PictureSourceType.CAMERA,
destinationType: this.camera.DestinationType.DATA_URL,
encodingType: this.camera.EncodingType.JPEG,
mediaType: this.camera.MediaType.PICTURE,
saveToPhotoAlbum:true,
}
this.camera.getPicture(options).then((imageData) => {
// imageData is either a base64 encoded string or a file URI
// If it's base64 (DATA_URL):
this.selectedImage = 'data:image/jpeg;base64,' + imageData;
}, (err) => {
// Handle error
});
在插件的文档中,建议将这些行添加到:
配置文件
</platform>
<edit-config target="NSCameraUsageDescription" file="*-Info.plist" mode="merge">
<string>need camera access to take pictures</string>
</edit-config>
<edit-config target="NSPhotoLibraryUsageDescription" file="*-Info.plist" mode="merge">
<string>need photo library access to get pictures from there</string>
</edit-config>
<edit-config target="NSLocationWhenInUseUsageDescription" file="*-Info.plist" mode="merge">
<string>need location access to find things nearby</string>
</edit-config>
<edit-config target="NSPhotoLibraryAddUsageDescription" file="*-Info.plist" mode="merge">
<string>need photo library access to save pictures there</string>
</edit-config>
解决方案
推荐阅读
- flutter - 颤振中的 setEnabledSystemUIOverlays 和 setPreferedOrientation
- javascript - 为什么当我按下这个按钮时一切都消失了?
- php - 功能显示 CRUD 在 Controller.php 中不起作用
- arrays - 使用 printf() 输出数组内容的问题
- r - 在 R 中汇总列表中的数据
- c# - Visual Studio - 热键跳转到调用函数的位置?
- json - 在 mongoDb 模式中声明 bsonType 数组
- asp.net-mvc - 有没有办法为每个控制器方法添加一个虚拟方法行为?(即记录)
- scala - play.application.loader [class java.lang.Class}] 没有实现接口 play.api.ApplicationLoader 或接口 play.ApplicationLoader
- onbase - 如何在 OnBase13 的重复部分上应用 SUM() 函数