ios - Phonegap 1.5 (Cordova) ios childbrowser 根本打不开

标签 ios plugins cordova xcode3.2

我是一个完整的 Phonegap 新手,所以如果可以的话请放轻松 :)

我已经安装了 phonegap 1.5 并且运行良好。我努力安装 childbrowser 插件,但我相信它现在已正确安装。但是,我似乎无法显示子浏览器?我尝试按照此处 ( http://bit.ly/ifK9lM ) 和此处 ( http://bit.ly/wOlq6k ) 的各种教程进行操作。我没有收到任何构建错误或控制台错误,但当我单击链接时子浏览器不显示。

当我单击我的按钮时,我在控制台中得到的只是“打开 Url:http://www.google.com”。所以就好像它在尝试...但我只是没有看到任何视觉输出??

我的 www 文件夹的根目录中有 ChildBrowser.js 文件和 cordova.js 文件。我已将所有子浏览器插件文件添加到我在 xcode 中的插件文件夹中。

我正在使用 Xcode 3.2.6

如果有人能提出我做错了什么,将不胜感激。

我不能在这里发布所有相关代码,因为它会失控。很高兴发布请求的代码。

这是我当前的 appdelegate.h 文件:

#import "AppDelegate.h"
#import "MainViewController.h"

#ifdef CORDOVA_FRAMEWORK
#import <Cordova/CDVPlugin.h>
#import <Cordova/CDVURLProtocol.h>
#else
#import "CDVPlugin.h"
#import "CDVURLProtocol.h"
#endif

#import "ChildBrowserCommand.h"
#import "ChildBrowserViewController.h"

@implementation AppDelegate

@synthesize invokeString, window, viewController;

//Code excluded for brevity here.....

#pragma UIWebDelegate implementation

- (void) webViewDidFinishLoad:(UIWebView*) theWebView 
{
// only valid if FooBar.plist specifies a protocol to handle
if (self.invokeString)
{
    NSString* jsString = [NSString stringWithFormat:@"var invokeString = \"%@\";", self.invokeString];
    [theWebView stringByEvaluatingJavaScriptFromString:jsString];
}

 // Black base color for background matches the native apps
theWebView.backgroundColor = [UIColor blackColor];

return [self.viewController webViewDidFinishLoad:theWebView];
}

- (void) webViewDidStartLoad:(UIWebView*)theWebView 
{
return [self.viewController webViewDidStartLoad:theWebView];
}

- (void) webView:(UIWebView*)theWebView didFailLoadWithError:(NSError*)error 
{
return [self.viewController webView:theWebView didFailLoadWithError:error];
}

- (BOOL) webView:(UIWebView*)theWebView shouldStartLoadWithRequest:                (NSURLRequest*)request navigationType:(UIWebViewNavigationType)navigationType
{
    return [self.viewController webView:theWebView shouldStartLoadWithRequest:request navigationType:navigationType];
}


- (void) dealloc
{
[super dealloc];
}

@end

这是我的 index.html:

<!DOCTYPE html>
<html>
<head>
<title></title>

<meta name="viewport" content="width=device-width, initial-scale=1.0, 
maximum-scale=1.0, user-scalable=no;" />
<meta charset="utf-8">
<script type="text/javascript" charset="utf-8" src="cordova-1.5.0.js"></script>
<script type="text/javascript" charset="utf-8" src="ChildBrowser.js"></script>

<script type="text/javascript">
var childBrowser;
function onBodyLoad()
{       
    document.addEventListener("deviceready", onDeviceReady, false);
}


function onDeviceReady()
{
    childBrowser = ChildBrowser.install();
}

function openChildBrowser(url)
{
    try {
        childBrowser.showWebPage(url);
    }
    catch (err)
    {
        alert(err);
    }
}

</script>
</head>
    <body onload="onBodyLoad()">
    <h1>Hey, it's Cordova!</h1>
    <button onclick="openChildBrowser('http://www.google.com');">Open Google</button>
</body>
</html>

最佳答案

布拉德

我遇到了与您相同的问题,并意识到这取决于我将文件添加到 Xcode 的方式。确保您确实将文件拖到 Xcode 中的 Plugins 文件夹中 - 不要只是将它们放在文件夹本身中。

还要确保添加 .xib 文件。如果您按照此处的说明进行操作:http://blog.digitalbackcountry.com/2012/03/installing-the-childbrowser-plugin-for-ios-with-phonegapcordova-1-5/他只提到添加 .h、.m 和捆绑文件,但从屏幕截图中您可以看到 xib 文件也在那里。

您可能还需要升级到 Xcode 4 - 适用于 Xcode 4.2 和 Cordova 1.5

关于ios - Phonegap 1.5 (Cordova) ios childbrowser 根本打不开,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9694537/

相关文章:

javascript - SumoSelect 重新加载后无法打开

grails - grails:gant无法解析调用类

android - 在 Android 中使用 HTML5 日期输入元素

ios - 如何找到应用程序/网站的深层链接?

javascript - 互联网连接检查不起作用

iphone - 警告将方法添加到核心数据的应用程序委托(delegate)中

ios - Swift 中的 UITableView 性能问题

java - 用于显示 Java 项目之间完整调用层次结构的 Eclipse 插件

ios - 在 Swift 中向数组添加一个元素

iphone - CFMutableAttributedString 在设备上运行时崩溃 (EXC_BAD_ACCESS)