Forced vertical screen on ios startup page (horizontal screen and vertical screen are allowed after entering App)

  • 2021-12-04 19:59:42
  • OfStack

This article mainly introduces the ios startup page forced vertical screen, after entering App allows horizontal screen and vertical screen related information, friends who need to refer to it.

The method is as follows

1. Modify App-info. plist (the effect of setting sample 1 in General in XCode)


 <key>UISupportedInterfaceOrientations</key>
 <array>
  <string>UIInterfaceOrientationPortrait</string>
 </array>

2. In AppDelegate:


- (UIInterfaceOrientationMask)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window {
 return UIInterfaceOrientationMaskAllButUpsideDown;
}

Stick 1 Apple's explanation of this, you can use it with confidence:

Discussion

This method returns the total set of interface orientations supported by the app. When determining whether to rotate a particular view controller, the orientations returned by this method are intersected with the orientations supported by the root view controller or topmost presented view controller. The app and view controller must agree before the rotation is allowed.

If you do not implement this method, the app uses the values in the UIInterfaceOrientation key of the app's Info.plist as the default interface orientations.

Summarize


Related articles: