- (BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
{
return YES;
}
- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
{
}
不工作,我不知道为什么。 当我尝试调试和旋转设备时,这些方法没有被调用。
我只想检测方向 如果方向 = 风景 执行 Action 别的 执行 Action b
非常感谢
最佳答案
我同意 Clafou 的观点,您的应用设置方式可能会影响旋转。
添加这个,看看它是否触发:
-(void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation {
BOOL isPortraitOrientation;
if ((self.interfaceOrientation == UIDeviceOrientationPortrait) || (self.interfaceOrientation == UIDeviceOrientationPortraitUpsideDown)){
isPortraitOrientation = YES;
} else if((self.interfaceOrientation == UIDeviceOrientationLandscapeLeft) || (self.interfaceOrientation == UIDeviceOrientationLandscapeRight)){
isPortraitOrientation = NO;
}
}
关于iphone - shouldAutorotateToInterfaceOrientation 不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9980077/