iphone - shouldAutorotateToInterfaceOrientation 不工作

标签 iphone ios

- (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/

相关文章:

iphone - 在 ios 6 中将图像附加到消息编辑器

iphone - ios 确定应用程序如何启动

iphone - Push Segue 未显示我的详细信息页面

iOS 等宽十六进制值

ios - 显示具有自定义边距的 .doc 文件

iphone - 从NSThread调用方法

.net - 确保 Web 服务安全

ios - 我对逃避关闭有点困惑

ios - AVPlayer 缓冲后停止播放视频

ios - UIButton 在 CABasicAnimation 期间不显示选定状态