tags:

views:

121

answers:

0

Hi, I simply can not get the UIDeviceOrientationDidChangeNotification to fire.

I have my AppDelegate, here I add a PolyOrientationViewController, which has a UInavigationController that can push a VerticalNavigationController and a HorizontalViewController depending on the orientation of the iPad.

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {    

    ISPolyOrientationTableViewController *pvc = [[ISPolyOrientationTableViewController alloc] init];
    [window addSubview:pvc.view];
    [pvc release];
    [window makeKeyAndVisible];

    return YES;
}

Poly, Vertical and Horizontal viewController implements:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    return YES;
}

PolyVC, which is the top most ViewController, it has these methods:

- (void)viewDidLoad {

    [[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didRotate:) 
                                                 name:UIDeviceOrientationDidChangeNotification
                                               object:nil];

    [super viewDidLoad];
}

It has the function related:

- (void)didRotate:(NSNotification *)notification {
    //push the related controller
}

Upon the instantiation of the PolyVC, the didRotate: method is called, from here on it simply stops generating the UIDeviceOrientationDidChangeNotification, I think.

I have a breakpoint in the didRotate: method, I have loaded the app onto an iPad to make sure it was not a simulator thing, I have made a new xcode splitViewController project, tested the rotation worked, deleted the code and pasted my own, I have checked the orientation-lock button, I have tried implementing the -(BOOL) ShouldAutoRotate… I is neither called, I checked that the info.plist specifies that the app supports all the orientations, I have tried copy pasting every piece of notification code from a working example I found to weed out typos.

I am completely at my wits end here:) Is there something I could have done, some way of implementing a UIViewController, not using IB, nesting ViewControllers inside ViewControllers (PolyViewController owns UINavigationController that owns Vertical and HorizontalViewController) or anything that will make the app completely ignore interfaceOrientation notifications?

I hope someone can point out my mistake :) Thank you in advance.