我想允许应该根据目标方向旋转
[[UIDevice currentDevice] orientation]
但是,上面的代码在 shouldRotate 中使用时保持当前(旧)方向,而不是目标方向
- (BOOL) shouldAutorotate {
return YES;
}
最佳答案
好吧,我明白了。在 shouldAutorotate 中始终返回 YES,然后执行以下操作:
- (NSUInteger)supportedInterfaceOrientations
{
if ([UIDevice currentDevice].orientation == UIDeviceOrientationLandscapeLeft) {
// Allow if you can
} else if ([UIDevice currentDevice].orientation == UIDeviceOrientationPortrait) {
// Allow if you can
}
// so on
}
关于cocoa - iOS6的目标方向shouldAutorotate,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12705348/