【发布时间】:2019-07-09 07:24:37
【问题描述】:
如何检查用户是否能够在activityViewController 期间保存到相机胶卷?
例如,我有一个活动视图控制器,它提供保存到相机胶卷的选项。用户保存图片后,我的应用会显示提示,让用户知道图片已保存。但是,当用户单击“保存到相机胶卷”图标时,操作系统会提示他授予权限,以便我的应用程序可以将照片存储在他们的相机胶卷上。如果用户拒绝权限,activityViewController.completionWithItemsHandler 仍然返回成功,即使用户没有将图片保存到相机中。
如何检查用户是否真的能够将图片保存到相机胶卷?
activityViewController.completionWithItemsHandler = { activity, success, items, error in
if success {
if let activity = activity {
switch activity {
case .postToFacebook:
self.view.showToast(with: "Successfully posted to Facebook.")
case .postToTwitter:
self.view.showToast(with: "Successfully posted to Twitter.")
case .message:
self.view.showToast(with: "Your message has been sent.")
case .mail:
self.view.showToast(with: "Your email has been sent.")
case .saveToCameraRoll:
if PHPhotoLibrary.authorizationStatus() == .denied {
self.view.show(alertForDeniedPermission(to: .photoLibraryAccess), animated: true)
} else {
self.view.showToast(with: "Your picture has been saved.")
}
default:
self.view.showToast(with: "Success!")
}
}
}
检查PHPhotoLibrary.authorizationStatus() 不起作用,因为枚举始终是. notDetermined。我想是因为我的应用只要求Privacy - Photo Library Additions Usage Description 而不是Privacy - Photo Library Usage Description。
【问题讨论】:
-
您将需要这 3 个在 plist 1 - 隐私 - 照片库使用说明 2 - 隐私 - 照片库添加使用说明 3 - 隐私 - 媒体库使用说明
-
您编写的代码应该将图像发布到 facebook。正确的 ?为什么要保存到相机胶卷?
标签: ios swift camera privacy phphotolibrary