gpt4 book ai didi

ios - PHPhotoLibrary requestAuthorization,不是请求

转载 作者:塔克拉玛干 更新时间:2023-11-02 09:58:18 32 4
gpt4 key购买 nike

为了测试,我试图重新创建系统“请求访问”弹出窗口体验。

更新:
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/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com