First: Manually set the rotation of the interface elements, including the status bar, navigation bar, and view. The following code is set to horizontal from the vertical screen, and the coordinate system is a vertical screen, so the coordinate values of negative numbers appear.
Set the status bar rotation
[[UIApplication sharedapplication] SetStatusBarOrientation:UIDeviceOrientationLandscapeRightanimated:YES];
CGFloat duration = [UIApplication sharedapplication].statusbarorientationanimationduration;
Set rotation animation
[UIView Beginanimations:nil Context:nil];
[UIView setanimationduration:duration];
Set the navigation bar rotation
Self.navigationController.navigationBar.frame = CGRectMake (-204, 224, 480, 32);
Self.navigationController.navigationBar.transform = Cgaffinetransformmakerotation (m_pi*1.5);
Set the view rotation
Self.view.bounds = CGRectMake (0, -54, Self.view.frame.size.width, self.view.frame.size.height);
Self.view.transform = Cgaffinetransformmakerotation (m_pi*1.5);
[UIView Commitanimations]
The second switch to the next page force a horizontal screen
if ([[Uidevice Currentdevice] Respondstoselector: @selector (setorientation:)]) {
SEL selector = nsselectorfromstring (@ "setorientation:");
Nsinvocation *invocation = [Nsinvocation invocationwithmethodsignature:[uidevice instancemethodsignatureforselector : selector]];
[Invocation setselector:selector];
[Invocation Settarget:[uidevice Currentdevice];
int val = uiinterfaceorientationlandscaperight;
[Invocation Setargument:&val atindex:2];
[Invocation invoke];
}
iOS Development Forced Portrait screen conversion