iPad app interface orientation changed after launc

2019-08-28 03:14发布

i am working on app. the orientation of app is landscape but after app run interface orientation of app change the interface and rotate. splash screen display in correct way (landscape). i am using ios7 the app was code for ios5 i think there is some deprecated api issue e.g. shouldAutorotateToInterfaceOrientation bot called because this is no more available in latest ios

enter image description here

5条回答
虎瘦雄心在
2楼-- · 2019-08-28 03:37

Try this:

- (BOOL)shouldAutorotate
{
    return YES;
}

- (NSUInteger)supportedInterfaceOrientations
{
    return UIInterfaceOrientationMaskLandscapeLeft | UIInterfaceOrientationMaskLandscapeRight;
}

EDIT :

See the attached link, might be helpful for you.

查看更多
看我几分像从前
3楼-- · 2019-08-28 03:38

use this in your Appdelegate.m

- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window
{
    NSLog(@"Interface orientations");
    if([[UIDevice currentDevice]userInterfaceIdiom]==UIUserInterfaceIdiomPad ){

        return UIInterfaceOrientationMaskLandScape;
    }
    else{
        return UIInterfaceOrientationMaskPortrait;
    }
}

It helped me..

查看更多
我欲成王,谁敢阻挡
4楼-- · 2019-08-28 03:42

enter image description here

you have to set orintatoin in build seeting see image.

it will solve your Problem.

查看更多
狗以群分
5楼-- · 2019-08-28 03:49

i find solution the think which i do is. step one override my UInavigationcontroller by creating a category

step two Replace [self.window addSubview:[navigationController view]]; //OLD

With [self.window setRootViewController:navigationController]; //NEW

查看更多
倾城 Initia
6楼-- · 2019-08-28 03:50

If you want all of our navigation controllers to respect the top view controller you can use a category so you don't have to go through and change a bunch of class names.

 @implementation UINavigationController (Rotation_IOS6)

-(BOOL)shouldAutorotate
{
   return [[self.viewControllers lastObject] shouldAutorotate];
 } 

-(NSUInteger)supportedInterfaceOrientations
{
    return [[self.viewControllers lastObject] supportedInterfaceOrientations];
}

- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
    return [[self.viewControllers lastObject]     preferredInterfaceOrientationForPresentation];
}

@end

As a few of the comments point to, this is a quick fix to the problem. A better solution is subclass UINavigationController and put these methods there. A subclass also helps for supporting 6 and 7.

查看更多
登录 后发表回答