2011-09-21 41 views
1

这里是我的代码:IOS力装置的旋转

if ([[UIApplication sharedApplication] statusBarOrientation] != UIInterfaceOrientationLandscapeLeft) { 
     [appDelegate makeTabBarHidden:TRUE]; 
     self.navigationController.navigationBarHidden = YES; 
     [UIView beginAnimations:@"newAlbum" context:NULL]; 
     [UIView setAnimationDelegate:self]; 
     [UIView setAnimationDidStopSelector:@selector(addResultGraph)]; 
     [[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationLandscapeLeft animated:YES]; 
     // Then rotate the view and re-align it: 
     CGAffineTransform landscapeTransform = CGAffineTransformMakeRotation(90.0 * M_PI/-180.0); 
     landscapeTransform = CGAffineTransformTranslate(landscapeTransform, +90.0, +90.0); 
     [self.navigationController.view setTransform:landscapeTransform]; 
     [UIView commitAnimations]; 
    } 

以及与此,从纵向模式时,新的视图 - 控制在landscapeleft模式下显示,并一切正常,但我的问题是:如果我旋转该设备从横向模式纵向,状态栏以纵向模式出现,并且视图控制器保持横向模式....

我该如何解决这个问题? 在此先感谢!

+0

工作正常如果我阻止iPhone旋转(绝对) – ghiboz

回答

4

您可以重新实现shouldAutorotateToInterfaceOrientation方法和做类似

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

这种方式,您只启用左排列,如果你旋转你的设备肖像,界面不会转动

+0

谢谢,我试过了,但方法没有被调用,似乎不正确的工作... – ghiboz

+0

好吧,解决了,我返回false,因为旋转它是我的实现,而不是自动旋转 – ghiboz