【发布时间】:2012-04-24 14:59:18
【问题描述】:
iPhone 具有仅用于纵向的方向锁定。所以我在我的 UI 中添加了一个横向锁定按钮,将landscape_orientation_locked 变量设置为YES 或NO。然后在shouldAutorotateToInterfaceOrientation:我基本上做了以下事情:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
if (landscape_orientation_locked)
return (UIInterfaceOrientationIsLandscape(interfaceOrientation));
return YES;
}
这很好用,除了一种情况。当我将 iPhone 转为横向时,切换方向锁定按钮,将 iPhone 旋转到纵向并再次按下该按钮。界面方向不会从横向变为纵向。 iPhone必须先变成横向再纵向才能触发界面旋转。
所以我的问题是:我能否以某种方式“强制”iPhone 重新评估其当前方向?
【问题讨论】: