如何在viewdidload中强制视图旋转到横向?

时间:2012-06-25 13:28:58

标签: ios5 uinavigationcontroller

Hi I'm using following code to show my app's login screen.   
LoginViewController * loginController = [[LoginViewController alloc] initWithNibName:@"LoginViewController" bundle:nil];
       UINavigationController * navController = [[UINavigationController alloc] initWithRootViewController:loginController];
       navController.modalPresentationStyle = UIModalPresentationFormSheet;
       [self.navigationController presentModalViewController:navController animated:YES];

正确加载。这里我的问题是我的应用程序应该只在横向模式下。这里我使用的是UIModalPresentationFormSheet,因此app会自动以纵向模式显示。我想强制我的应用程序在加载此登录视图后更改为横向模式。在加载这个UIModalPresentationFormSheet之后,请帮助我如何将我的视图旋转到横向模式。 (这意味着在LoginViewController的viewDidLoad模式中,我必须强制我的应用程序更改为横向模式。我怎样才能实现这一点)。提前致谢

1 个答案:

答案 0 :(得分:0)

尝试使用横向坐标值重写用户界面框架属性。

中执行此操作
- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
                                         duration:(NSTimeInterval)duration

并附带条件

 [super willAnimateRotationToInterfaceOrientation:toInterfaceOrientation duration:duration];

if (toInterfaceOrientation == UIInterfaceOrientationLandscapeLeft
    ||  toInterfaceOrientation == UIInterfaceOrientationLandscapeRight)
相关问题