Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ios 6 App is rotating, even with shouldAutorotate:NO

since iOS6 i have big problems with the rotation. I implemented all the new rotation methods (shouldAutorotate, preferredInterfaceOrientationForPresentation, supportedInterfaceOrientation), but all views are still rotating. The funny thing is that the views are keeping their sizes and the rest of the Window (in Landscape) is black.

Thats the way i implement it, is there anything wrong?

#pragma mark -
#pragma mark - InterfaceOrientation iOS 5 
//Deprecated in iOS 6
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    // Return YES for supported orientations
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

#pragma mark -
#pragma mark - InterfaceOrientation iOS 6

- (BOOL)shouldAutorotate{
    return NO;
}

- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation{
    return UIInterfaceOrientationPortrait;
}

- (NSUInteger)supportedInterfaceOrientations{
    return UIInterfaceOrientationMaskPortraitUpsideDown;
}

Thanks for your help folks.

like image 817
Fry Avatar asked Oct 08 '12 07:10

Fry


1 Answers

I solved the Problem by making a category for the navigationcontroller:

@implementation UINavigationController (iOS6fix)

-(BOOL)shouldAutorotate
{
    return [[self.viewControllers lastObject] shouldAutorotate];
}

-(NSUInteger)supportedInterfaceOrientations
{
    return [[self.viewControllers lastObject] supportedInterfaceOrientations];
}

- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
    return [[self.viewControllers lastObject] preferredInterfaceOrientationForPresentation];
}

@end

Thanks to everyone for the answers!

like image 168
Fry Avatar answered Sep 28 '22 08:09

Fry