我有类似的问题。创建在info.plist中一个关键NSPhotoLibraryUsageDescription要解决这个问题,但事实并非如此,这里是一个编程修复:
func photoLibraryAvailabilityCheck() {
let status = PHPhotoLibrary.authorizationStatus()
if (status == PHAuthorizationStatus.authorized) {
print("PHAuthorizationStatus.authorized")
} else if (status == PHAuthorizationStatus.denied) {
print("PHAuthorizationStatus.denied")
requestPhotosLibraryAccess()
} else if (status == PHAuthorizationStatus.notDetermined) {
print("PHAuthorizationStatus.notDetermined")
requestPhotosLibraryAccess()
} else if (status == PHAuthorizationStatus.restricted) {
print("PHAuthorizationStatus.restricted")
}
}
func requestPhotosLibraryAccess() {
PHPhotoLibrary.requestAuthorization({ (newStatus) in
if (newStatus == PHAuthorizationStatus.authorized) {
print("pressed the allowed button")
} else {
print("pressed the don't allow button")
}
})
}
使用:
photoLibraryAvailabilityCheck()
见http://stackoverflow.com/问题/ 13635288/IOS-日历访问权限的对话框的力就到出现/ 13693935#13693935。这适用于所有隐私设置。 – rmaddy
另请参阅http://stackoverflow.com/questions/12810638/app-crashed-in-ios-6-when-user-changes-contacts-access-permissions/12810719#12810719了解关于“编辑”的信息。 – rmaddy
@rmaddy,有趣。谢谢您的帮助! – Stonep123