How do I force a specific UIInterfaceOrientation on an individual view in a UINavigationController?

后端 未结 8 891
闹比i
闹比i 2020-12-14 17:27

Okay, so here\'s the situation:

I have an app in which I only want ONE specific view in a UINavigationController to have a landscape orientation. This view is a UIIm

8条回答
  •  Happy的楠姐
    2020-12-14 18:10

    You can try to force Device to rotate to necessary orientation - but you need to handle it manually (in addition to overriding UIViewController orientation handling methods).

    To rotate device you can use next methods:

    [[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationLandscapeRight];
    

    But in it may not work in all situations...

    Also available undocumented approach:

    [[UIDevice currentDevice] performSelector:NSSelectorFromString(@"setOrientation:")
                                           withObject:(__bridge id)((void*)UIInterfaceOrientationLandscapeLeft)];
    

提交回复
热议问题