【问题标题】:lock orientation programmatically in iOS 9在 iOS 9 中以编程方式锁定方向
【发布时间】:2015-09-14 18:51:00
【问题描述】:

作为标题,我想知道现在是否可以在 iOS 9 中以编程方式锁定方向?这对我的应用程序至关重要,但我找不到办法。谢谢。

【问题讨论】:

标签: ios9 device-orientation


【解决方案1】:

使用supportedInterfaceOrientations 和preferredInterfaceOrientationForPresentation 来管理方向 例如

-(UIInterfaceOrientationMask)supportedInterfaceOrientations{
    return UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskPortraitUpsideDown;
}

- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation{
    return UIInterfaceOrientationPortrait;
}

【讨论】:

  • 你的viewcontroller在navegationController还是tabbarcontroller里面?
  • 导航控制器内部,也就是tabbarcontroller内部。
  • 工作就像一个魅力
  • 帮我找出问题所在。导航控制器正在处理所有掩码
  • 如果viewcontroller在navigationController下,则需要为navigationController添加一个类,并将上面的代码放入navigationController的类中。
猜你喜欢
  • 1970-01-01
  • 2016-05-26
  • 1970-01-01
  • 2013-10-13
  • 1970-01-01
  • 2011-09-08
  • 2015-01-23
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多