Rya*_*yan 28 mobile-safari url-scheme ios
iOS URL Schemes允许网站启动这样的应用程序:
twitter://timeline
推出Twittergooglechrome://google.com
推出Chromefb://root
推出Facebook______________
推出Safari?(不是http://
,因为Safari不会启动UIWebView
)什么自定义网址方案触发Safari启动(甚至从另一个应用程序内UIWebView
)?
澄清一下,我不是在寻找 [[UIApplication sharedApplication] openURL: request.URL];
相反,我正在寻找一个网站如何允许用户从UIWebView
另一个应用程序(谷歌浏览器,推特等)内启动移动Safari .
弹出其他应用程序的示例HTML链接:
<a href="twitter://timeline">Open Twitter</a>
<a href="googlechrome://google.com">Open site in Chrome</a>
<a href="fb://root">Open Facebook</a>
Run Code Online (Sandbox Code Playgroud)
我正在寻找类似于这些非工作示例的东西:
<a href="safari://google.com">Open Safari [Doesn't work]</a>
<a href="webkit://google.com">Open Webkit [Doesn't work]</a>
Run Code Online (Sandbox Code Playgroud)
这是一个相同的jsFiddle:http://jsfiddle.net/gXLjF/9/embedded/result/
尝试在iOS Google Chrome中打开此网址,然后使用这些链接打开Safari.
没有 Safari URL 方案。如果你编写了一个并在你的 html 中使用它,你可以检查它。
实施该UIWebViewDelegate
方法webView:shouldStartLoadWithRequest:navigationType:
。对于您想要分流到 mobile safari 的请求,返回“NO”。UIApplication
openURL
使用请求的 URL 进行调用。
像这样的东西:
- (BOOL) webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType
{
// all clicked links!
if ( navigationType == UIWebViewNavigationTypeLinkClicked )
{
[[UIApplication sharedApplication] openURL: request.URL];
return NO;
}
// or, custom URL scheme!
if ( [request.URL.scheme isEqualToString: @"my-open-in-safari"] )
{
// remap back to http. untested!
NSURL* url = [NSURL URLWithString: [request.URL.absoluteString stringByReplacingOccurrencesOfString: @"my-open-in-safari" withString: @"http" ]];
[[UIApplication sharedApplication] openURL: url];
return NO;
}
return YES;
}
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
22968 次 |
最近记录: |