hwa*_*xer 16 uiapplication ios ios6
从iOS6开始,我无法判断应用程序是否可以启动Safari.
如果Safari在设备上受到限制(设置>常规>限制),尝试打开URL时没有任何反应,并且没有指示出现了什么问题:
NSURL *url = [NSURL URLWithString:@"http://www.google.com"];
[[UIApplication sharedApplication] canOpenURL:url]; // Returns YES
[[UIApplication sharedApplication] openURL:url]; // Returns YES
Run Code Online (Sandbox Code Playgroud)
但是,Safari 无法启动,用户不知道为什么我的按钮"坏了".
这似乎是一个错误,所以我提交了一个雷达#12449905.
有没有其他方法可以解决这个问题?
如果这是 Apple 的错误,那么看起来您要做的就是围绕它进行编程。一旦用户单击按钮,您始终可以编写如下内容:
[self performSelector:@selector(notifyUserOfRestrictedAccess) withObject:self afterDelay:.5];
Run Code Online (Sandbox Code Playgroud)
在应用程序委托中,您可以设置一个属性,例如:
- (void)applicationWillResignActive:(UIApplication *)application {
self.openingExternalProgram = YES;
}
Run Code Online (Sandbox Code Playgroud)
在您的视图控制器中,创建如下方法:
-(void) notifyUserOfRestrictedAccess {
if (!appDelegate.openingExternalProgram) {
// Message the user via UIAlertView about restricted Safari access
}
appDelegate.openingExternalProgram = NO;
}
Run Code Online (Sandbox Code Playgroud)
我确信有更好的方法,但至少你不必等待苹果。
| 归档时间: |
|
| 查看次数: |
4093 次 |
| 最近记录: |