The iOS 6 SDK has changed the previous method of controlling uiviewcontroller. To be compatible with iOS 5 and iOS 6, you need to make necessary adjustments to the code. Because the structure of each application is different, I only talked about the application structure of uitabbarcontroller + uinavigationcontroller in this article. In addition, I listed some solutions at the end. If the methods in this Article do not work for your problem, you can try the solutions provided by the listed connections.
1. Enable the orientation switch supported by the device on the Project Settings page, for example:
2. Set the rootviewcontroller of the window.
In appdelegate. H
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{ ...... self.window.rootViewController = tabBarController; self.window.backgroundColor = [UIColor whiteColor]; [self.window makeKeyAndVisible]; return YES;}
3. Add the category of uitabbarcontroller
@ Implementation uitabbarcontroller (background)-(bool) shouldautorotate {// here I first set automatic rotation to no from the global perspective, because every uiviewcontroller does not need to be automatically rotated. Return no;}-(nsuinteger) supportedinterfaceorientations {// return uiinterfaceorientationmaskportrait;} @ end @ implementation appdelegate
4. Add the following code to the. M file of the uiviewcontroller that requires automatic rotation
// Rotation control method before iOS 5-(bool) orientation :( uiinterfaceorientation) interfaceorientation {If ([uidevice currentdevice] userinterfaceidiom] = uiuserinterfaceidiomphone) {return (interfaceorientation! = Uiinterfaceorientationportraitupsidedown) & (interfaceorientation! = Uiinterfaceorientationlandscapeleft) & (interfaceorientation! = Uiinterfaceorientationlandscaperight);} else {return yes;}/rotation control method of iOS 6-(bool) shouldautorotate {return yes;}-(nsuinteger) supportedinterfaceorientent{ return response ;}
5. For other solutions, refer
Http://stackoverflow.com/questions/12522903/uitabbarcontroller-rotation-issues-in-ios-6