Cordova(Phonegap)和iFrames *绝望 [英] Cordova (Phonegap) and iFrames *Desperate

查看:105
本文介绍了Cordova(Phonegap)和iFrames *绝望的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

似乎每个人都知道愚蠢的小,但在phonegap,不允许你有iFrames在你的应用程序。有许多修复,但它们是为遗留版本的phonegap,不工作或导致其他问题。这是我到目前为止所尝试的:

It seems everyone knows about the dumb little but in phonegap that doesn't allow you to have iFrames in your application. There are a number of fixes out there but they are either for legacy versions of phonegap, don't work or cause other issues. Here is what I have tried so far:


  1. OpenAllWhitelistURLsInWebView

http://craigpfau.com/2012/02/phonegap-ios-uiwebview-and-safari-app-links/

这是我想要完成的:


  1. 视频嵌入来自vimeo(iframe)留在应用程序中,externalhosts:vimeo.com a。 vimeocdn.com b.vimeocdn.com

  2. 所有其他链接都出于safari

是我的应用详细信息:

ios 5.1.1 | Cordova 1.7.0 | JqueryMobile | Jquery 1.7.1

ios 5.1.1 | Cordova 1.7.0 | JqueryMobile | Jquery 1.7.1

推荐答案

我有一个示例应用程序这里打开应用程序中的Vimeo视频,但打开Safari中的其他网址。

I have a sample application here which does open the Vimeo video inside the app but opens the other urls in Safari.

我在MainViewController.m中更改了以下函数

I changed the below function in 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];
}

这篇关于Cordova(Phonegap)和iFrames *绝望的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆