2011-08-09 50 views
2

我使用NativeControls插件,在我的PhoneGap iOS应用程序的本地footerbar。NativeControls和设备的方向

当我旋转我的iPhone时,页脚也旋转,但它只显示一个没有任何图标的黑色栏......当我移动到另一页时,整个界面完全破碎,我需要重新启动应用程序。

有谁知道如何解决它?也许NativeControls插件与横向不兼容?对于设备旋转

回答

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解雇。 Inside 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]; 
} 
+0

我有同样的确切问题。但是,我似乎没有MainViewcontroller.m文件。你能澄清那件吗? –