ios - PHPhotoLibrary requestAuthorization,不是请求
<p><p>为了测试,我试图重新创建系统“请求访问”弹出窗口体验。</p>
<p><strong>更新:</strong><br/>
iOS 11下,删除App后,会再次出现系统弹窗。</p>
<hr/>
<p><em>(上一个问题)</em></p>
<p>App 第一次运行时(也是<strong>唯一</strong> 次),系统弹出窗口显示,请求访问。之后,<strong>即使不删除应用程序并重新启动设备</strong>也会再次触发该弹出窗口。</p>
<p>换句话说,设备“记住”了用户请求并且无法重置。</p>
<p>代码如下:</p>
<pre><code>[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;
}
}];
</code></pre>
<p>当设置中的访问关闭时,它会一直打印“PHAuthorizationStatusDenied”。但不显示任何弹出窗口。立即返回。</p>
<p>建议将“Bundle display name”添加到 plist。用空值、$(PRODUCT_NAME) 和不同的字符串尝试过,但无济于事。</p>
<p>清理项目,删除 DrivedData(并每次都从模拟器中删除 App)。运气不好。</p>
<p><strong>更多信息:</strong></p>
<p>一旦您在“设置”中关闭照片访问权限,Apple 示例代码“SamplePhotosApp”就会崩溃。</p></p>
<br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
<p><p>进一步阅读后,这似乎是设计使然。</p>
<p><strong>来自 Apple:</strong></p>
<blockquote>
<p>This method always returns <strong>immediately</strong>. If the user has <strong>previously</strong>
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.</p>
</blockquote>
<p>如果用户提示一次,则说“此方法总是<strong>立即</strong>”。之后它不会再显示请求。好像没办法(不过是一些自定义消息)再用系统消息。</p></p>
<p style="font-size: 20px;">关于ios - PHPhotoLibrary requestAuthorization,不是请求,我们在Stack Overflow上找到一个类似的问题:
<a href="https://stackoverflow.com/questions/35083401/" rel="noreferrer noopener nofollow" style="color: red;">
https://stackoverflow.com/questions/35083401/
</a>
</p>
页:
[1]