IPhone Development notes (21) iOS 6 Rotation Problem Solution Summary

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.