Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/37.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
可编程iPhone横向方向锁_Iphone_Locking_Landscape - Fatal编程技术网

可编程iPhone横向方向锁

可编程iPhone横向方向锁,iphone,locking,landscape,Iphone,Locking,Landscape,iPhone有一个方向锁,仅用于纵向。因此,我在我的UI中添加了一个横向方向锁定按钮,该按钮将横向方向锁定变量设置为是或否。然后在shouldAutorotateToInterfaceOrientation:中,我基本上执行以下操作: - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { if (landscape_orientation_locked)

iPhone有一个方向锁,仅用于纵向。因此,我在我的UI中添加了一个横向方向锁定按钮,该按钮将
横向方向锁定
变量设置为
。然后在
shouldAutorotateToInterfaceOrientation:
中,我基本上执行以下操作:

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

  return YES;
}
除了一种情况外,这种方法效果很好。当我将iPhone转到横向时,切换方向锁定按钮,将iPhone旋转到纵向,然后再次按下按钮。界面方向不会从横向更改为纵向。iPhone必须先转向横向,然后转向纵向,才能触发界面旋转


因此,我的问题是:我是否可以“强制”iPhone重新评估其当前方向?

呈现并取消模拟模态视图控制器应该强制进行方向检查

编辑:找到了我第一次读到的问题:


我也读到了关于这个把戏的报道。不幸的是,它似乎不再起作用了。