iphone:在导航时强制改变从纵向到横向的方向 [英] iphone: Forcefully change orientation from portrait to landscape on navigation

查看:224
本文介绍了iphone:在导航时强制改变从纵向到横向的方向的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有什么方法可以在导航时强制将应用方向从纵向更改为横向?

Is there any way that we can Forcefully change app orientation from portrait to landscape while navigating ?

我要求将控制器从A推送到B. B应该是横向的,但是我的A控制器是纵向的。

I have a requirement that while pushing controller from A to B. B should be in landscape but my A controller is in portrait.

推荐答案

在你的ViewController-B中,在viewDidLoad中添加以下代码行:

In your ViewController-B add this lines of code in viewDidLoad:

  [[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationLandscapeRight];

  float   angle = M_PI/2;  //rotate 180°, or 1 π radians
  self.view.layer.transform = CATransform3DMakeRotation(angle, 0, 0.0, 1.0);

如果您使用导航控制器从A移动到B,此代码工作正常。

This code is working fine if you are using navigation controller to move from A to B.

我用过这个。

希望这会对你有帮助。

享受编码:)

这篇关于iphone:在导航时强制改变从纵向到横向的方向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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