对于我们的iPad应用程序,我希望允许以横向模式(而不是纵向)自动旋转屏幕以支持两种可能的方向。但是,我们的应用程序中有部分用户需要摇动并将iPad移动到方向和方向,这将触发自动旋转功能但不应该。
是否可以取消并重新激活自动方向,以便在进入应用程序的此部分时锁定方向并在退出时解锁?
答案 0 :(得分:1)
如果特定部分表示另一个视图控制器,则可以是
只需将此行代码添加到控制器..
// which orientation that this view controller support
- (NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskPortrait;
}
// prevent rotation
- (BOOL)shouldAutorotate
{
return NO;
}
// after present this view controller, which orientation do you prefer ?
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
return UIInterfaceOrientationPortrait;
}