简体   繁体   English

在iOS 7中将方向颠倒时视图不会旋转

[英]view does not rotate when orientation is upsidesidedown in ios 7

I tring to make app support all orientation. 我试图使应用程序支持所有方向。 Its working fine but only upside down orientation is not working. 它的工作正常,但只有倒置方向无效。 I am using ios7. 我正在使用ios7。 For upside down the view does not rotate. 对于倒置,视图不旋转。 I tried following code 我尝试了以下代码

-(BOOL)shouldAutorotate  
{
return yes;
}
-(NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskAll; // etc
}

My only second method is called but not first method. 我唯一的第二种方法叫做,但第一种方法不是。 In infoPlist I enabled all the supported orientations. 在infoPlist中,我启用了所有受支持的方向。

Found the fix. 找到了解决方法。 Sourced mainly from: https://stackoverflow.com/a/12758715/394969 主要来源: https : //stackoverflow.com/a/12758715/394969

In a nutshell for people who land here first: 概括地说,首先登陆这里的人:

/* In your view controller */
// Add support for upside down 
-(NSUInteger)supportedInterfaceOrientations
{
    return UIInterfaceOrientationMaskAll;
}

Also flip on all device orientations in project settings as outlined in @Jignesh Mayani's answer. 也可以按@Jignesh Mayani的答案中所述在项目设置中翻转所有设备方向。 If that doesn't immediatley fix your issue check the link above for how to work with nav controllers and tab controllers (they all must support the required interface orientations). 如果那不能立即解决您的问题,请检查上面的链接,了解如何使用导航控制器和选项卡控制器(它们都必须支持所需的界面方向)。

Confirm that you have check, Go your project setting and Check 确认您已检查,进入项目设置并检查 在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM