点击按钮锁定iPad方向

3
在我的基于的应用程序中,点击按钮将初始化拍照功能。我需要连续拍摄五张照片。一旦我按下按钮,我需要锁定当前方向,并且这五张照片应该在这个特定的方向中拍摄。例如,如果当前是横向模式,并且我按下按钮,则这五张照片应该在横向模式下拍摄。 我目前正在使用以下代码。它可以工作,但不是完美的,有一个延迟时间。只有在几秒钟后按下按钮后才会被锁定。
// End notifying the orientation change
[[UIDevice currentDevice] endGeneratingDeviceOrientationNotifications];

// Begin notifying the orientation change
[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];

您能否提供任何解决此问题的方案?

提前致谢。

1个回答

2

重写shouldAutorotate方法(我在iOS6上测试过它可以工作):

- (BOOL)shouldAutorotate
{
    return !self.isLocked;
}

- (IBAction)buttonClicked:(id)sender
{
    self.isLocked = !self.isLocked;
}
@end

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接