Eri*_*ric 6 iphone cocoa-touch objective-c orientation ipad
在我的应用程序中的某个时刻,我想暂时禁用旋转功能 - 有效地"锁定"代码中的方向,类似于锁定切换开关在iPad上的硬件操作.
我现在正在做:
[[UIDevice currentDevice] endGeneratingDeviceOrientationNotifications]
Run Code Online (Sandbox Code Playgroud)
当我通过时,我打电话给:
[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications]
Run Code Online (Sandbox Code Playgroud)
虽然这一切看起来都有效,但是API文档表明应该始终有一个开头,然后是结束 - 我基本上是反过来的.是否有更合适的API来处理"锁定方向"?
slf*_*slf 10
我认为这很简单,因为没有响应控制器的方向变化.您可以有条件地返回true或false,具体取决于您传递的参数,您不必总是返回true.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
if (rand()%2 == 0) { // evaluate if I should allow rotate
return YES;
} else {
return NO;
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
7471 次 |
| 最近记录: |