Apparently all I have to do is create a view-based application, toAutoRotateToInterfaceOrientaion for YES, and create two subclasses of uiviewcontroller with separate xib files, and then add this to the application view controller:
[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(orientationChanged) name:UIDeviceOrientationDidChangeNotification object:nil];
and add this method to the application view controller:
-(void)orientationChanged { UIDeviceOrientation orientation = [UIDevice currentDevice].orientation; if (orientation == UIDeviceOrientationPortrait || orientation == UIDeviceOrientationPortraitUpsideDown) { [[NSBundle mainBundle] loadNibNamed:@"Portrait" owner:self options:nil]; } else { [[NSBundle mainBundle] loadNibNamed:@"Landscape" owner:self options:nil]; } }
and this, when the device is rotated, xib automatically boots in the correct orientation.
edit: you also need to programmatically add two view managers (@property and @synthesize), as well as two view managers in appviewcontroller.xib in IB, each of which has a class name corresponding to a subclass of viewcontroller of each xib you create. then add a view, connect it to the file owner and connect the sockets in IB to the view controllers that you created in ib, and that should be all
Joe
source share