0

バージョン 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 のプラグインの違いは何ですか?

4

2 に答える 2

2

エラーの理由はwindow.plugins、Cordovaでサポートされなくなったことです。

ソリューション:

呼び出し元のスクリプトを次のように変更します(おそらくonDeviceReady()関数内です。controls.jsこれを使用する場合は、ファイル内にある可能性があります。

// nativeControls = window.plugins.nativeControls; // get rid of (or comment out)
   nativeControls = new NativeControls(); // use this line instead

修正され、Cordova2.0で動作します:-)

お役に立てば幸い

補遺:実際には、これは途中でしか得られません-xCodeファイルを編集する必要がありますNativeControls.m

于 2012-09-20T13:18:04.567 に答える
0

これに関する GitHub プロジェクトは次のとおりです: https://github.com/zSprawl/NativeControls

プロジェクトをダウンロードして xcode 4.x で開くだけです。

于 2012-07-24T14:32:50.127 に答える