【问题标题】:how to force view to rotate to landscape in viewdidload?如何在 viewdidload 中强制视图旋转到横向?
【发布时间】:2012-06-25 13:28:58
【问题描述】:
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 模式下,我必须强制我的应用更改为横向模式。我该如何实现)。提前致谢

【问题讨论】:

    标签: ios5 uinavigationcontroller


    【解决方案1】:

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

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

    附带条件

     [super willAnimateRotationToInterfaceOrientation:toInterfaceOrientation duration:duration];
    
    if (toInterfaceOrientation == UIInterfaceOrientationLandscapeLeft
        ||  toInterfaceOrientation == UIInterfaceOrientationLandscapeRight)
    

    【讨论】:

      最近更新 更多