Javascript Cordova 1.9和本机控件插件兼容性

Javascript Cordova 1.9和本机控件插件兼容性,javascript,cordova,Javascript,Cordova,我看到在cordova/phonegao版本1.6之前,本机控件插件工作得很好。但我无法使用此代码使其继续工作: newLoc = location.href.substring(0, location.href.lastIndexOf("/") + 1); // Initializating TabBar nativeControls = window.plugins.nativeControls; nativeControls.createTabBar(); // Back Button n

我看到在cordova/phonegao版本1.6之前,本机控件插件工作得很好。但我无法使用此代码使其继续工作:

newLoc = location.href.substring(0, location.href.lastIndexOf("/") + 1);
// Initializating TabBar
nativeControls = window.plugins.nativeControls;
nativeControls.createTabBar();
// Back Button
nativeControls.createTabBarItem("page1", "Page 1", "www/images/pound.png", {
    "onSelect": function() {
        $.mobile.changePage("#page1", {
            transition: 'reverse slide'
        });
        nativeControls.setNavBarTitle("Page 1");
        nativeControls.selectTabBarItem("page1");
        selectedTabBarItem = "page1";
    }
});
// Home tab
nativeControls.createTabBarItem("page2", "Page 2", "www/images/pound.png", {
    "onSelect": function() {
        if (selectedTabBarItem == "page1") {
            $.mobile.changePage("#page2", {
                transition: 'slide'
            });
        } else {
            $.mobile.changePage("#page2", {
                transition: 'reverse slide'
            });
        }
        nativeControls.setNavBarTitle("Page 2");
        nativeControls.selectTabBarItem("page2");
        selectedTabBarItem = "page2";
    }
});
// About tab
nativeControls.createTabBarItem("page3", "Page 3", "www/images/question.png", {
    "onSelect": function() {
        $.mobile.changePage("#page3", {
            transition: 'slide'
        });
        nativeControls.setNavBarTitle("Page 3");
        nativeControls.selectTabBarItem("page3");
        selectedTabBarItem = "page3";
    }
});
// Compile the TabBar
nativeControls.showTabBar();
nativeControls.showTabBarItems("page1", "page2", "page3");
selectedTabBarItem = "page1";
nativeControls.selectTabBarItem("page1");
// Setup NavBar
nativeControls.createNavBar();
nativeControls.setNavBarTitle("Page 1");
nativeControls.setupLeftNavButton("?", "", "onLeftNavButton");
//nativeControls.hideLeftNavButton();
nativeControls.setupRightNavButton("About", "", "onRightNavButton");
nativeControls.showNavBar();
}
查看js文件,现在似乎需要cordova.exec()

有人把它弄好了吗?
iOS插件和iPhone插件有什么区别?

以下是GitHub项目:

只需下载项目并在xcode 4.x中打开它
希望这有帮助

错误的原因是
window.plugins
在Cordova中不再受支持

解决方案:

按如下方式修改调用脚本(可能在
ondevicerady()
函数中-如果使用
controls.js
文件,则可能在该文件中:

// nativeControls = window.plugins.nativeControls; // get rid of (or comment out)
   nativeControls = new NativeControls(); // use this line instead
固定并使用Cordova 2.0:-)

希望有帮助


附录:事实上,这只会让你得到一部分-你仍然需要编辑xCode文件
NativeControls.m

是的,我看到了,但它针对Cordova 1.7进行了优化,无论如何,我让它与TabBar和NavigationBar一起工作。无论如何,谢谢你。