Supports horizontal screen rotation for iOS devices
Ios devices support rotation methods:
1. Modify the info of the project. the value of "Supported interface orientations" in plist (generally, you can check the Taget-> General-> Deployment Info-> Device Orientation in the project to select Device Support ).
2. Implement the (application: supportedInterfaceOrientationsForWindow :) method in the AppDelegate file of the project. In this method, return the direction enumeration supported by the program.
3. To implement a ViewController that supports rotation after iOS6.0, you can use the following two methods:
-(BOOL) shouldAutorotate {// whether rotation is supported
Return YES;
}
-(NSUInteger) supportedInterfaceOrientations {// orientation of rotation supported
ReturnUIInterfaceOrientationMaskPortrait;
}
Extension:
If the program interface requires only vertical screens, but the webView pop-up video in the project requires horizontal screen playback, you can solve the problem by combining the above mentioned methods in 1st and 2.
Solution: Modify the project info. plist value so that it only supports the Portrait direction; then implement application: supportedInterfaceOrientationsForWindow: method, and return the UIInterfaceOrientationMaskAllButUpsideDown value in this method. In this way, even if a program is started on a horizontal screen on the iPhone 6 P or ipad, the screen will not appear, and video playback on the iPhone still supports horizontal screen.
The above questions are resolved:
You can modify info. plist to enable the device to support all directions, and change the screen width and height obtained by [UIScreen mainScreen]. bounds.
Implement application: supportedInterfaceOrientationsForWindow: The method supports all directions without changing the wide and high values corresponding to [UIScreen mainScreen]. bounds.
The conjecture caused by the above problem is not verified. If there is anything wrong, please correct it ....