【问题标题】:Programatic iPhone landscape orientation lock程序化 iPhone 横向锁定
【发布时间】:2012-04-24 14:59:18
【问题描述】:

iPhone 具有仅用于纵向的方向锁定。所以我在我的 UI 中添加了一个横向锁定按钮,将landscape_orientation_locked 变量设置为YESNO。然后在shouldAutorotateToInterfaceOrientation:我基本上做了以下事情:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
  if (landscape_orientation_locked)
    return (UIInterfaceOrientationIsLandscape(interfaceOrientation));

  return YES;
}

这很好用,除了一种情况。当我将 iPhone 转为横向时,切换方向锁定按钮,将 iPhone 旋转到纵向并再次按下该按钮。界面方向不会从横向变为纵向。 iPhone必须先变成横向再纵向才能触发界面旋转。

所以我的问题是:我能否以某种方式“强制”iPhone 重新评估其当前方向?

【问题讨论】:

    标签: iphone locking landscape


    【解决方案1】:

    呈现然后关闭模拟模式视图控制器应该强制进行方向检查。

    编辑:发现我第一次读到的问题:

    Is there a documented way to set the iPhone orientation?

    【讨论】:

    • 我也读到过这个技巧。不幸的是,它似乎不起作用(不再起作用了?)。
    猜你喜欢
    • 2011-04-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-11-13
    • 1970-01-01
    相关资源
    最近更新 更多