Ios UIC应用程序';s-canOpenURL:-openURL:返回误导性结果

Ios UIC应用程序';s-canOpenURL:-openURL:返回误导性结果,ios,ios6,uiapplication,Ios,Ios6,Uiapplication,由于iOS6,我无法判断应用程序是否可以启动Safari 如果Safari在设备上受到限制(设置>常规>限制),则在尝试打开URL时不会发生任何事情,并且没有迹象表明发生了什么错误: NSURL *url = [NSURL URLWithString:@"http://www.google.com"]; [[UIApplication sharedApplication] canOpenURL:url]; // Returns YES [[UIApplication sharedApplicat

由于iOS6,我无法判断应用程序是否可以启动Safari

如果Safari在设备上受到限制(设置>常规>限制),则在尝试打开URL时不会发生任何事情,并且没有迹象表明发生了什么错误:

NSURL *url = [NSURL URLWithString:@"http://www.google.com"];
[[UIApplication sharedApplication] canOpenURL:url]; // Returns YES
[[UIApplication sharedApplication] openURL:url]; // Returns YES
但是,Safari不会启动,用户会疑惑为什么我的按钮“坏了”

这对我来说似乎是一个错误,所以我申请了一个雷达#12449905


有没有其他方法可以解决这个问题?

如果这是一个苹果bug,那么看起来你要做的就是围绕它编程。一旦用户单击按钮,您就可以编写如下内容:

[self performSelector:@selector(notifyUserOfRestrictedAccess) withObject:self afterDelay:.5];
-(void) notifyUserOfRestrictedAccess {

    if (!appDelegate.openingExternalProgram) {
        // Message the user via UIAlertView about restricted Safari access
    }
    appDelegate.openingExternalProgram = NO;
}
在应用程序委托中,您可以设置以下属性:

- (void)applicationWillResignActive:(UIApplication *)application {
    self.openingExternalProgram = YES;
}
在视图控制器中,创建如下方法:

[self performSelector:@selector(notifyUserOfRestrictedAccess) withObject:self afterDelay:.5];
-(void) notifyUserOfRestrictedAccess {

    if (!appDelegate.openingExternalProgram) {
        // Message the user via UIAlertView about restricted Safari access
    }
    appDelegate.openingExternalProgram = NO;
}

我相信有更好的方法,但至少你不必等待苹果。

雷达是公共的吗?除了我自己提交的搜索雷达的按钮外,我找不到任何“搜索”按钮…@jcayzac没有,但我将其添加到openradar:它是否与https://一起工作?由于这是一个bug,它可能只是随机决定使用不同的URL方案,而没有明显的原因。将URL发送到应用程序中的UIWebView可能是一种解决方法。@PartiallyFinite
https
@好奇兔可能对一些人有效,但仍然不能解决问题。谢谢。。。听通知绝对是一种更好的方式。