- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
为了测试,我试图重新创建系统“请求访问”弹出窗口体验。
更新:
iOS 11下,删除App后,会再次出现系统弹窗。
(上一个问题)
App 第一次运行时(也是唯一 次),系统弹出窗口显示,请求访问。之后,即使不删除应用程序并重新启动设备也会再次触发该弹出窗口。
换句话说,设备“记住”了用户请求并且无法重置。
代码如下:
[PHPhotoLibrary requestAuthorization:^(PHAuthorizationStatus status) {
switch (status) {
case PHAuthorizationStatusAuthorized:
NSLog(@"PHAuthorizationStatusAuthorized");
break;
case PHAuthorizationStatusDenied:
NSLog(@"PHAuthorizationStatusDenied");
break;
case PHAuthorizationStatusNotDetermined:
NSLog(@"PHAuthorizationStatusNotDetermined");
break;
case PHAuthorizationStatusRestricted:
NSLog(@"PHAuthorizationStatusRestricted");
break;
}
}];
当设置中的访问关闭时,它会一直打印“PHAuthorizationStatusDenied”。但不显示任何弹出窗口。立即返回。
建议将“Bundle display name”添加到 plist。用空值、$(PRODUCT_NAME) 和不同的字符串尝试过,但无济于事。
清理项目,删除 DrivedData(并每次都从模拟器中删除 App)。运气不好。
更多信息:
一旦您在“设置”中关闭照片访问权限,Apple 示例代码“SamplePhotosApp”就会崩溃。
最佳答案
进一步阅读后,这似乎是设计使然。
来自 Apple:
This method always returns immediately. If the user has previously granted or denied photo library access permission, it executes the handler block when called; otherwise, it displays an alert and executes the block only after the user has responded to the alert.
如果用户提示一次,则说“此方法总是立即”。之后它不会再显示请求。好像没办法(不过是一些自定义消息)再用系统消息。
关于ios - PHPhotoLibrary requestAuthorization,不是请求,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35083401/
我一直在尝试寻找一种替代方法,以在 iOS 8 中使用 Photos API 获取相册名称。使用 ALAssets,我们可以使用:valueForProperty:ALAssetsGroupPrope
我正在为 Mac OS X (10.11) 开发照片扩展。 我导入了 Photos 和 PhotosUI 框架。 除了我尝试调用 PHPhotoLibrary.sharedPhotoLibrary()
我有一个 NSURLDownloadTask 可以在后台成功下载文件(大图像或视频文件)。我成功地复制了 url 并调用此函数将我的 url 保存到照片库。如您所见,我想发送一个 UILocalNot
随着 iOS 8 中的新功能,如果您在应用程序中使用相机,它会请求访问相机的权限,然后当您尝试重新拍摄照片时,它会请求访问照片库的权限。下次我启动应用程序时,我想检查相机和照片库是否有访问权限。 对于
我正在尝试将视频保存到我的照片库中。但有时我会得到一个错误:操作无法完成。 (PHPhotosErrorDomain 错误 -1。) 这是我的代码: PHPhotoLibrary.shared().p
我触发了图像的后台下载。它成功了 - 位置是实际图像的路径。我没有收到错误消息,但图像也没有显示在照片应用程序中。我已经设置了 NSPhotoLibraryUsageDescription Info.
要将图像导出到手机图库,我尝试使用 ALAssetsLibrary,但 Xcode 8.0 通知我该方法已弃用,我应该使用 PHPhotoLibrary。当我使用 ALAssetsLibrary 时,
我正在使用 PHPhotoLibrary 创建自定义文件夹并在其中添加图片。它工作正常,但我添加到自定义文件夹的图片也会添加到“相机胶卷”文件夹中。我找到了这个旧线程Add photos in cus
我正在尝试从 ALAssetsLibrary 转换为 PHPhotoLibrary,因为它已被弃用。我需要从照片库中选择的照片中获取日期,但无法找出正确的方法。这是我目前正在做的事情。 mediaUr
我正在检查相机胶卷的权限: -(void)viewDidAppear:(BOOL)animated { [super viewDidAppear:YES]; PHAuthorizati
在测试我的应用程序时,我希望能够重置 +[PHPhotoLibrary authorizationStatus] 以检查应用程序在库未获得授权时是否正常运行。 我已尝试删除并重新安装应用程序,但是,授
为了测试,我试图重新创建系统“请求访问”弹出窗口体验。 更新: iOS 11下,删除App后,会再次出现系统弹窗。 (上一个问题) App 第一次运行时(也是唯一 次),系统弹出窗口显示,请求访问。之
我曾经使用 ALAssetLibrary 的 writeImageToSavedPhotosAlbum:metadata:completionBlock 将照片保存到相机胶卷,但现在在 iOS 9.0
我在应用程序中具有将图片保存在照片库中的功能。我想知道如何测试这段代码: func saveInPhotoGallery() { guard self.cameraOutput != nil
我似乎遇到了一个我不知道为什么会发生的随机问题。我似乎无法让观察者调用 photoLibraryDidChange:(PHChange *)changeInstance。我做了几个空白项目,所有项目都
我想做的是将视频保存到 PHPhotoLibrary,然后在上传到应用程序中的客户端远程服务器完成时删除它们(基本上,照片库用作临时存储以添加额外的安全层以防万一失败(我已经将我的视频保存在应用程序目
我在两种情况下使用 UIImagePickerController 选择照片库中的现有图像 拍一张新照片 在第一种情况下,当我从库中选择图像时,我可以轻松地在委托(delegate)方法中获取 URL
大家好,我正在使用 ALAssetsLibrary 将视频/图像写入相册。但 XCode 告诉我 ALAssetsLibrary 已被弃用,我需要使用 PHPhotoLibrary,这一切都很好,但没
我正在使用以下代码将图像保存到我在 iOS 照片库中创建的自定义文件夹中: 我收到此错误:Error Domain=NSCocoaErrorDomain Code=-1 "(null)" 谁能帮我解决
对于 iOS9,ALAssetsLibrary 已弃用。那么如何将其更改为 PHPPhotoLibrary 而不是 ALAssets? if (RecordedSuccessfully && reco
我是一名优秀的程序员,十分优秀!