似乎每个人都知道愚蠢的小,但在PhoneGap中,不允许你在你的应用程序中使用iFrame.有很多修复,但它们要么是旧版本的PhoneGap,要么不起作用或导致其他问题.这是我到目前为止所尝试的:
http://craigpfau.com/2012/02/phonegap-ios-uiwebview-and-safari-app-links/
似乎没什么用.这是我想要完成的事情:
这是我的应用详情:
ios 5.1.1 | Cordova 1.7.0 | JqueryMobile | Jquery 1.7.1
我在这里有一个示例应用程序,可以在应用程序中打开Vimeo视频,但在Safari中打开其他URL.
我在MainViewController.m中更改了以下函数
- (BOOL) webView:(UIWebView*)theWebView shouldStartLoadWithRequest:(NSURLRequest*)request navigationType:(UIWebViewNavigationType)navigationType
{
NSURL *url = [request URL];
NSString *host = [request.URL host];
if(host != NULL || host != nil){
if ([host rangeOfString:@"vimeo.co"].location != NSNotFound) {
return YES;
}else{
if ([[url scheme] isEqualToString:@"http"] || [[url scheme] isEqualToString:@"https"]) {
[[UIApplication sharedApplication] openURL:url];
return NO;
}
else {
return [ super webView:theWebView shouldStartLoadWithRequest:request navigationType:navigationType ];
}
}
}
return [super webView:theWebView shouldStartLoadWithRequest:request navigationType:navigationType];
}
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
3527 次 |
最近记录: |