Jon*_*ski 3 iphone xamarin.ios ios4
我们有一个iphone应用程序,它托管一个Web浏览器控件,该控件指向一个网站,其唯一目的是显示应用程序的信息.我想知道是否可以使用HTML/JavaScript打开锚点/按钮打开Safari.如果有可能,怎么样?
谢谢...
您可以为正在使用的UIWebview设置委托.在这个委托中,写下这样的东西:
-(bool) webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType
{
//You might need to set up an "interceptLinks"-Bool since you don't want to intercept the initial loading of the content
if (self.interceptLinks) {
NSURL *url = request.URL;
//This launches Safari with your URL
[[UIApplication sharedApplication] openURL:url];
return NO;
}
//No need to intercept the initial request to fill the WebView
else {
self.interceptLinks = TRUE;
return YES;
}
}
Run Code Online (Sandbox Code Playgroud)
如果您只想拦截某些链接,则可以解析该网址,并在必要时仅打开Safari.
| 归档时间: |
|
| 查看次数: |
2604 次 |
| 最近记录: |