我看到原生控件插件在 1.6 版之前的 cordova/phonegao 上运行良好。但我不能再用这段代码让它工作了:
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 有什么区别?