我可以格式化URL以从我的应用程序的UIWebView中启动Safari吗?

我的应用程序有一个显示相当数量内容的UIWebView。对于某些内容,我想退出应用程序,并启动Safari来处理Web内容,而不是在我的UIWebView中执行。是否有一个url格式将显式启动Safari而不是在UIWebView中加载页面? 显然我不能使用http://因为它只是打开了url。我可以使用safari://或类似的东西吗? 编辑:道歉,我原来不清楚。我正在寻找一个解决方案,涉及更改网页上的网址而不修改我的客户端。希望通过tel://为手机启用本机Safari启动模式。     
已邀请:
当然。然后让
UIWebView
代表做:
- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType {
  NSString * customScheme = @"safari";

  NSURL * loadURL = [request URL];  //this is the url the user tapped
  if ([[loadURL scheme] isEqual:customScheme]) {
    //if the url starts with "safari://"
    NSString * absoluteURL = [loadURL absoluteString];
    //replace "safari" with "https"
    absoluteURL = [absoluteURL stringByReplacingCharactersInRange:NSMakeRange(0,[customScheme length]) withString:@"https"];
    NSURL * openURL = [NSURL URLWithString:absoluteURL];
    //open the URL in MobileSafari
    [[UIApplication sharedApplication] openURL:openURL];
    //tell your UIWebView to ignore this request
    return NO;
  } else {
    //this is not a safari:// url, so handle it normally
    return YES;
  }
}
    

要回复问题请先登录注册