2012-05-02 33 views
0

我正在构建一个iPad应用程序,所有视图都应该自动旋转。一种观点让我头痛。ipad应用程序 - 大多数视图旋转确定。一个视图不

我知道这个问题的变体已经被问了几次前,但我无法通过调用应用程序的程序找到一个可行的解决方案..

我翻到这一观点。代表。这个例程的代码是:

- (void)flipToBack { 
    //NSLog(@"%s", __FUNCTION__); 

    DrawingViewController *drawView = [[DrawingViewController alloc] initWithNibName:@"Draw" bundle:nil]; 
    [self setDrawingViewController:drawView]; 
    [UIView beginAnimations:nil context:NULL]; 
    [UIView setAnimationDuration:1.0]; 
    [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:window cache:YES]; 

    [self.window addSubview:[drawView view]]; 
    [UIView commitAnimations]; 

    // NSLog (@" FINISHED "); 
} 

这是一个视图控制器(mvc)与UIView子视图,后者,绘图发生。 mvc和子视图都不能正常旋转。

我使用调用在MVC旋转的代码是:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 
{ 
    return YES; 
} 

MVC的有两个工具栏,顶部和底部,而这些都需要调整。无论轮换如何,这些也应该保持顶部和底部。

项目总结显示所有方向都受支持,但我认为这仅适用于应用程序。初始化。

我所有的支持mvc。

我正在创建的工具栏是这样的:

UIInterfaceOrientation fieldOrient = [[UIApplication sharedApplication] statusBarOrientation]; 
    if ((fieldOrient == UIDeviceOrientationLandscapeLeft) || (fieldOrient == UIDeviceOrientationLandscapeRight)) { 
     CGRect frame = CGRectMake(0, 50, 1024, 35); 
     topToolbar.frame = frame; 
    } else { 
     CGRect frame = CGRectMake(0, 50, 768, 35); 
     topToolbar.frame = frame; 


UIInterfaceOrientation fieldOrient = [[UIApplication sharedApplication] statusBarOrientation]; 
    if ((fieldOrient == UIDeviceOrientationLandscapeLeft) || (fieldOrient == UIDeviceOrientationLandscapeRight)) { 
     CGRect frame = CGRectMake(0, 650, 1024, 35); 
     bottomToolbar.frame = frame; 
    } else { 
     CGRect frame = CGRectMake(0, 950, 768, 35); 
     bottomToolbar.frame = frame; 

我想我失去了一些东西明显..任何帮助/指针将不胜感激。

回答

0

对我的答案是呈现视图为模式图。这不是理想的,但它的工作原理。

1

尝试在将旋转到接口取向方法设置帧:

- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration { 

    if ((toInterfaceOrientation == UIDeviceOrientationLandscapeLeft) || (toInterfaceOrientation == UIDeviceOrientationLandscapeRight)) { 
     CGRect frame = CGRectMake(0, 650, 1024, 35); 
     bottomToolbar.frame = frame; 
    } else { 
     CGRect frame = CGRectMake(0, 950, 768, 35); 
     bottomToolbar.frame = frame; 
} 
+0

或者,您可以在创建工具栏时设置自动调整大小的蒙版。 – scord

+0

我很抱歉,但我已经增加了更多的问题,并可能会改变你的答案的代码.. –

+0

我试过你的解决方案,但没有喜悦:( –