如何在viewdidload中强制视图旋转到横向? [英] how to force view to rotate to landscape in viewdidload?

查看:68
本文介绍了如何在viewdidload中强制视图旋转到横向?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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模式中,我必须强制我的应用程序更改为横向模式。我怎样才能实现这一点)。提前致谢

Its loading properly. Here my problem is my app should be in landscape mode only. Here I'm using UIModalPresentationFormSheet so app is automatically appearing in portrait mode. I would like to force my app to change to landscape mode after this login view loads. some one please help me how to rotate my view into landscape mode after this UIModalPresentationFormSheet loads. (It means in LoginViewController's viewDidLoad mode I have to force my app to change to landscape mode. How can I achieve that). Thanks in advance

推荐答案

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

Try re-writing your User Interface Frame attributes with landscape co-ordinate values.

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

和附带条件

 [super willAnimateRotationToInterfaceOrientation:toInterfaceOrientation duration:duration];

if (toInterfaceOrientation == UIInterfaceOrientationLandscapeLeft
    ||  toInterfaceOrientation == UIInterfaceOrientationLandscapeRight)

这篇关于如何在viewdidload中强制视图旋转到横向?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆