使用以下https://github.com/apache/incubator-cordova-mac制作mac os x应用程序,但似乎我无法获得打开的_blank链接。如果有人知道那会是多么好。
答案1) - 没有用
我把它放在WebViewDelegate.m -
中UIWebViewNavigationType<是错误
- (BOOL) webView:(WebView*)theWebView shouldStartLoadWithRequest:(NSURLRequest*)request navigationType:(UIWebViewNavigationType)navigationType
{
//return [self.viewController webView:theWebView shouldStartLoadWithRequest:request navigationType: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"] || [[url scheme] isEqualToString:@"itms-apps"]) {
[[UIApplication sharedApplication] openURL:url];
return NO;
}
else {
return [self.viewController webView:theWebView shouldStartLoadWithRequest:request navigationType:navigationType];
}
}
答案 0 :(得分:2)
我认为_blank更改是最新版本,尚未在iOS中实现。我目前在AppDelegate.m
中使用这段本机代码在Safari中打开外部网址
- (BOOL) webView:(UIWebView*)theWebView shouldStartLoadWithRequest:(NSURLRequest*)request navigationType:(UIWebViewNavigationType)navigationType
{
//return [self.viewController webView:theWebView shouldStartLoadWithRequest:request navigationType: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"] || [[url scheme] isEqualToString:@"itms-apps"]) {
[[UIApplication sharedApplication] openURL:url];
return NO;
}
else {
return [self.viewController webView:theWebView shouldStartLoadWithRequest:request navigationType:navigationType];
}
}
答案 1 :(得分:0)
此适用于2.3.0 oO'
- (BOOL) webView:(UIWebView*)theWebView shouldStartLoadWithRequest:(NSURLRequest*)request navigationType:(UIWebViewNavigationType)navigationType{
//return [self.viewController webView:theWebView shouldStartLoadWithRequest:request navigationType: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"] || [[url scheme] isEqualToString:@"itms-apps"]) {
[[UIApplication sharedApplication] openURL:url];
return NO;
}
else {
return [ super webView:theWebView shouldStartLoadWithRequest:request navigationType:navigationType ];
}}