Search code examples
objective-cios6uiinterfaceorientation

When rotating my viewController, the status bar doesn't rotate with the with. How to fix it?


Everyone. I've got an iOS6 ipad app to update. The problem I met is that only one view controller needs autorotate, and I don't find out the correct method to do this.

I've tried the following link and it partly helped: Only having one view autorotate in xcode?

But when I rotate the viewController, its status bar doesn't rotate with the view and the title of the view doesn't stay in the center as I set.

I add breakpoints in the viewController, and find that only when the device is landscape does it calls - (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration.

I wonder if anyone can tell me where the bug hides and how to fix it. Thanks in forward.


Solution

  • I've solved this problem. My mistake is that I added some words below when setting the autorotation issue.

    CGAffineTransform landscapeTransform = CGAffineTransformMakeRotation(degreesToRadian(0));
    landscapeTransform = CGAffineTransformTranslate (landscapeTransform, 0.0, 0.0);
    
    self.view.bounds = CGRectMake(self.view.bounds.origin.x, self.view.bounds.origin.y, 768, 1024);
    
    if (isVisible == NO) return; // iOS present modal bodge
    [self updateScrollViewContentViews]; // Update content views
    lastAppearSize = CGSizeZero; // Reset view size tracking
    
    [self.view setTransform:landscapeTransform];
    

    I deleted these manual words and leave the following methods alone. It's done.

    -(NSUInteger)supportedInterfaceOrientations {
        return UIInterfaceOrientationMaskAll;
    }
    
    - (BOOL)shouldAutorotate
    {
        return YES;
    }
    
    - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
    {
        return YES;
    }