iphone:在导航时强制将方向从纵向更改为横向

iphone: Forcefully change orientation from portrait to landscape on navigation(iphone:在导航时强制将方向从纵向更改为横向)
本文介绍了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.

我用过这个.

希望这会对你有所帮助.

Hope this will help you.

享受编码:)

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

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

Pushing UIViewController above UITabBar(将UIView控制器推送到UITabBar上方)
How to stop UIBarButtonItem text from truncating?(如何阻止UIBarButtonItem文本被截断?)
java.lang.IllegalStateException: SimpleTypeImpl should not be created for error type(异常:不应为错误类型创建SimpleTypeImpl)
Android IllegalArgumentException: The tag for fragment_XXX is invalid. Received: layout-sw600dp/fragment_XXX_0(Android IlLegalArgumentException:Fragment_XXX的标签无效。收到:Layout-sw600dp/Fragment_XXX_0)
iOS convert audio sample rate from 16 kHz to 8 kHz(IOS将音频采样率从16 kHz转换为8 kHz)
Enforcing an audio sampling rate in iOS(在iOS中强制音频采样率)