2

PhoneGap iOS アプリで NativeControls プラグインとネイティブ フッターバーを使用しています。

iPhoneを回転させると、フッターバーも回転しますが、アイコンのない黒いバーしか表示されません...そして、別のページに移動すると、インターフェース全体が完全に壊れており、アプリを再起動する必要があります.

誰もそれを解決する方法を知っていますか? もしかして、NativeControls プラグインが横向きに対応していないのでしょうか?

4

1 に答える 1

0

デバイス ローテーションのサポートは、実際には実装されていませんでした。手順は次のとおりです。

1) オリエンテーション リスナーを追加します。

document.addEventListener("orientationChanged",redrawTabBar,false);

2) 向きが変わったときに呼び出される関数を追加します。

function redrawTabBar() {
    if (navigator.notification){
        PhoneGap.exec("NativeControls.redrawTabBar");
    }
}

3) 実際のプラグイン (.m) にメソッドを追加します。

- (void)redrawTabBar:(NSArray*)arguments withDict:(NSDictionary*)options
{
    tabBar.frame=CGRectMake(0, self.webView.frame.size.height, self.webView.frame.size.width, 50);
}

4) orientationChanged イベントが webview によって発生することを確認します。MainViewcontroller.m 内

- (void)didRotateFromInterfaceOrientation: (UIInterfaceOrientation)fromInterfaceOrientation
{
int i = 0;  
    switch (self.interfaceOrientation){
        case UIInterfaceOrientationPortrait:
            i = 0;
            break;
        case UIInterfaceOrientationPortraitUpsideDown:
            i = 180;
            break;
        case UIInterfaceOrientationLandscapeLeft:
            i = -90;
            break;
        case UIInterfaceOrientationLandscapeRight:
            i = 90;
            break;
    }

    NSString* jsString = 
    @"(function(){"
    "var e = document.createEvent('Events');"
    "e.initEvent('orientationChanged');"
    "document.dispatchEvent(e);"
    "})();";
    NSLog(@"Orientation Changed");
    [self.webView stringByEvaluatingJavaScriptFromString:jsString];
}
于 2012-03-31T14:15:22.977 に答える