Rahul Vyas
Rahul Vyas

Reputation: 28740

Strange iOS6 AutoRotate Bug

I'm Using this category for supporting Auto rotation in ios 6

@implementation UINavigationController (RotationIn_IOS6)

-(BOOL)shouldAutorotate
{
    NSLog(@"Last Object is %@",[[self.viewControllers lastObject] description]);
    return [[self.viewControllers lastObject] shouldAutorotate];
}

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

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

My application setup is like this

  1. show password screen with Navigation Controller rotation works fine for both(Simulator,Device).
  2. Authenticate user and show home Screen rotation only works in simulator not in device

-(BOOL)shouldAutorotate

is implemented in home screen Anyone knows how to solve this ?

Upvotes: 0

Views: 106

Answers (1)

Mike Pollard
Mike Pollard

Reputation: 10195

According to the answer to this question using a Category to override a method in a Cocoa class is a bad idea. 'the behavior is undefined as to which method implementation is used at runtime'.

I use a subclass of UINavigationController to achieve what you are trying to do and haven't had any problems so I suggest you try that instead.

Upvotes: 1

Related Questions