When iOS 8 rotates horizontally, the View does not rotate as the device rotates and is fixed.

Asked 2 years ago, Updated 2 years ago, 94 views

Xcode6, Objective-c creates an application that allows you to switch between vertical and horizontal screens with buttons.
(Vertical and horizontal screens have different designs and functions.)
When viewing a vertical screen, use the Portrait button to secure the screen
The horizontal screen rotates with the right of the Home button (LandScapeRight) and
I would like to allow the left (LandScapeLeft) to rotate.

The rotation of the device is managed by shouldAutorotate.

@implementation UINavigationController (rotateControl)

- (NSUInteger) supported Interface Orientations
{
    return [self.visibleViewController supportedInterfaceOrients];
}

- (BOOL) shouldAutorotate
{
    return YES;
}

@end

Portrait is fixed for vertical screen.

 - (NSUInteger) supported InterfaceOrients
{
    return UIInterfaceOrientationMaskPortrait;
}

When viewing horizontally, it is fixed with Landscape.

 - (NSUInteger) supported InterfaceOrients
{
    return UIInterfaceOrientationMaskLandscape;
}

Horizontal screen orientation is accompanied by the status bar (device).
I want the horizontal screen to rotate up and down, so

Application preferences to Device Orientation Check "Landscape Left" and "Landscape Right".

Enter a description of the image here

However, if you run it on the actual iPhone 6 Plus (iOS8)
If you rotate it 180 degrees during the horizontal screen,
The position of the status bar always moves upward, but
As a result, the UIView does not rotate and remains fixed.
(This is expected for iOS 7 iPhone 5, iPhone 6 and iPhone 6 Plus simulators.)

As the status bar (device) rotates
What should I do to turn the horizontal screen up and down?
I'm having a hard time because I've been stuck for days...
Thank you for your cooperation.

objective-c xcode6 ios8

2022-09-30 11:08

2 Answers

Enable 180 degree rotation in the application preferences before programming.

Enter a description of the image here

Device Orientation is disabled by default, so check and enable Upside Down.


2022-09-30 11:08

Apparently, this is unique to iOS 8's iPhone 6 Plus and iPad.

Device rotation is detected by the NSNotificationCenter class and
By adding an affine conversion rotation animation to the View when rotating the device
As the device spins, the View also spins.

[UIView animationWithDuration: 0.5f // Animation Speed]
                      delay: 0.0f // How many seconds will it take to animate?
                    options:UIViewAnimationOptionCurveEaseIn
                 animations:^{
                       // Rotate the view 180 degrees
                       float angle = 180.0*M_PI/180;
                       CGAffineTransform t2 = CGAffineTransformRotate(t1,angle);

                 } completion:^(BOOL finished) {
                     // at the end of animation
                     NSLog (@ "End Animation");
                 }];


2022-09-30 11:08

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.