简体   繁体   English

方向不支持ios6设备

[英]orientation not supporting in ios6 devices

i have an application build on xcode 4.2 , which supports only portrait orientation, it works fine with all devices except ios6 .. In Ios 6 devices it is showing both orientations .. I need only portrait orientation .. i am using navigation controller .. IN appdelegate:: 我有一个基于xcode 4.2的应用程序,它只支持纵向方向,它适用于除ios6之外的所有设备..在Ios 6设备中它显示两个方向..我只需要纵向...我正在使用导航控制器.. IN appdelegate ::

- (BOOL)shouldAutorotate
{

      return ([[UIDevice currentDevice] orientation]==UIInterfaceOrientationPortrait);
}


- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window
{
     return (UIInterfaceOrientationMaskPortrait);
}

in other viewControllers :: 在其他viewControllers ::

- (BOOL)shouldAutorotate {
    return YES;
}

- (void)viewDidLayoutSubviews
{
    DisplayFunctionName;
    NSLog(@"orientation: %d",self.interfaceOrientation);
}

- (NSUInteger)supportedInterfaceOrientations
{
    if (UI_USER_INTERFACE_IDIOM()==UIUserInterfaceIdiomPad)
    {
        return (UIInterfaceOrientationMaskAll);
    }
    else
    {
        return (UIInterfaceOrientationMaskPortrait);
    }
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    DisplayFunctionName;
    NSLog(@"orientation: %d",interfaceOrientation);
      return (interfaceOrientation==UIInterfaceOrientationPortrait);

}

In IOS6 handling of Orientation is difficult is case when you want portrait orientation for some views and for some you want landscape orientation, but its very easy if you want only one orientation support for entire app. 在IOS6中,当您想要某些视图的纵向方向以及某些您想要横向方向时,处理方向很困难,但如果您只想为整个应用程序提供一个方向支持,则非常容易。 simple go to Supporting Files and then open the info.plist in your app and remove all other orientation except one that you want.. below are few screen shot which help you to fix your issue 简单转到支持文件 ,然后在您的应用程序中打开info.plist并删除除您想要的所有其他方向..下面是几个屏幕截图,可以帮助您解决问题

在此输入图像描述

在此输入图像描述

after removing all other orientation your info.plist will be looks like below 删除所有其他方向后,您的info.plist将如下所示 在此输入图像描述

i hope it works for you.Thanks 我希望它适合你。谢谢

iOS 6 iOS 6

shouldAutorotateToInterfaceOrientation : is deprecated and replaced by shouldAutorotateToInterfaceOrientation :已弃用并替换为

shouldAutorotate shouldAutorotate

Check this : https://stackoverflow.com/a/14938444/305135 请查看: https//stackoverflow.com/a/14938444/305135

Try using these , 尝试使用这些,

- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
    return UIInterfaceOrientationPortrait;
}

- (NSUInteger)supportedInterfaceOrientations
{
    return UIInterfaceOrientationPortrait;
}

- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window
{
    return UIInterfaceOrientationPortrait;
}

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

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