gpt4 book ai didi

html - 如何在 Safari 中打开 phonegap 子浏览器中显示的链接?

转载 作者:行者123 更新时间:2023-11-28 02:10:59 25 4
gpt4 key购买 nike

我有一个 phone gap 应用程序,它在子浏览器中加载 HTML 5 应用程序。在子浏览器中加载的页面上的链接也会在子浏览器中加载。我希望这些链接在 Safari 中打开。我该怎么做?

谢谢

最佳答案

你只需要在你的 AppDelegate.m 中添加这个

- (BOOL)webView:(UIWebView *)theWebView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType
{
NSURL *url = [request URL];

// Intercept the external http requests and forward to Safari.app
// Otherwise forward to the PhoneGap WebView
if ([[url scheme] isEqualToString:@"http"] || [[url scheme] isEqualToString:@"https"]) {
[[UIApplication sharedApplication] openURL:url];
return NO;
}
else {
return [ super webView:theWebView shouldStartLoadWithRequest:request navigationType:navigationType ];
}
}

希望对你有帮助

关于html - 如何在 Safari 中打开 phonegap 子浏览器中显示的链接?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8393296/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com