2012-06-25 88 views
1
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,所以應用程序自動以縱向模式顯示。我想強制我的應用程序在加載此登錄視圖後更改爲橫向模式。有些人請幫助我在UIModalPresentationFormSheet加載後如何將視圖旋轉到橫向模式。 (這意味着在LoginViewController的viewDidLoad模式,我必須強迫我的應用程序更改爲橫向模式,我該如何實現這一點)。在此先感謝如何強制視圖旋轉到viewdidload中的橫向?

回答

0

嘗試重新編寫您的用戶界面框架屬性與景觀座標值。

- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation 
             duration:(NSTimeInterval)duration 

和前提

[super willAnimateRotationToInterfaceOrientation:toInterfaceOrientation duration:duration]; 

if (toInterfaceOrientation == UIInterfaceOrientationLandscapeLeft 
    || toInterfaceOrientation == UIInterfaceOrientationLandscapeRight) 
做到這一點