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

后端 未结 8 902
闹比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条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-14 18:15

    Just override this UIViewController method to only return true for landscape like so and the iphone will be forced to rotate to that device orientation, since it has no other option.

    - (BOOL)shouldAutorotateToInterfaceOrientation: (UIInterfaceOrientation)interfaceOrientation {
        return (interfaceOrientation == UIInterfaceOrientationLandscapeRight);
    }
    

提交回复
热议问题