Tuesday, August 7, 2012

iOS 6 Auto Rotate and Orientation Changes on MonoTouch 5.99 (alpha)

In iOS6, auto rotate and orientation changes have changed quite significantly.

In a nutshell, these are the steps I took to upgrade my monotouch project to work with the new changes:


1. You will need to assign a root view controller to your main application window on FinishedLaunching. This is the crucial bit! I spent quite sometime figuring this out. Basically if you don't set your root view controller, you will get a warning in build output that looks like this: 

Application windows are expected to have a root view controller at the end of application launch

So if previously like me you have this in your FinishedLaunching(UIApplication app) method in main.cs:
window.AddSubview(mainVC.View);

Replace it with this:
window.RootViewController = mainVC;


2. Replace this:
public override bool ShouldAutorotateToInterfaceOrientation (UIInterfaceOrientation toInterfaceOrientation)

With these two lines:

public override bool ShouldAutorotate()
public override UIInterfaceOrientationMask SupportedInterfaceOrientations()


Obviously you will need to specify the orientation masks your view controller support in SupportedInterfaceOrientstions(). For example, if you support all orientations you might want to do this:

public override bool ShouldAutorotate()
{
return true;
}

public override UIInterfaceOrientationMask SupportedInterfaceOrientations()
{
return UIInterfaceOrientationMask.All;

}

That's my experience in getting auto rotation to work in ios 6 on MonoTouch 5.99. Check out the full release notes in the developer portal or if you don't have a login, you can check it out here.

41 comments:

  1. it should be: public override UIInterfaceOrientationMask GetSupportedInterfaceOrientations ()

    Otherwise great post!

    ReplyDelete
  2. Finally! Point 1was the one little thing I missed.
    Thanks :)

    ReplyDelete
  3. Great job for publishing such a beneficial web site. Your web log isn’t only useful but it is additionally really creative too. There tend to be not many people who can certainly write not so simple posts that artistically. Continue the nice writing
    uber unsere fair-dienst auf Website

    ReplyDelete
  4. Gud information about iOS 6 Auto Rotate and Orientation.
    microsoft dynamics crm course

    ReplyDelete
  5. Best Information on IOS 6 Auto Rotation and Orientation well While i was in kuwait where my PMP Certification in Kuwait has been taken and was also undergoing some project's in that one of them is IOS well thankyou for the blog

    ReplyDelete
  6. Australia Best Tutor is one of the best Online Assignment Help providers at an affordable price. Here All Learners or Students are getting best quality assignment help with reference and styles formatting.

    Visit us for more Information

    Australia Best Tutor
    Sydney, NSW, Australia
    Call @ +61-730-407-305
    Live Chat @ https://www.australiabesttutor.com




    Our Services

    Online assignment help Australia
    my assignment help Australia
    assignment help
    help with assignment
    Online instant assignment help
    Online Assignment help Services

    ReplyDelete
  7. Informative Blog on iOS 6 Auto Rotate and Orientation Changes on MonoTouch ... Thanks for your Valuable Information... MindMajix is providing Online Training on IOS Development Training.

    ReplyDelete
  8. Your blog is very useful for me, Thanks for your sharing.

    ReplyDelete

  9. When cooking with oil, you will see the fact that smoke usually receives emitted in case you often uses the identical oil. Typically, these form of eating places have today's hoods as well as exhaust fans.
    Visit here
    Kitchen Chimney Repair Service in Noida
    Kitchen Kitchen Chimney Repair Service in Vaishali
    Kitchen Kitchen Chimney Repair Service in indirapuram
    Kitchen Kitchen Chimney Repair Service in vasundhra
    Kitchen Kitchen Chimney Repair Service in faridabad

    ReplyDelete
  10. This comment has been removed by the author.

    ReplyDelete
  11. Hi, Thanks for sharing nice information about Code. Anyone interest to learn Best Digital Marketing Course in Ameerpet . Best institutes is Hyderabad Digital Marketing Institutes they provide all concepts SEO,SMM,SMO ADwords, Affiliate Marketing.

    ReplyDelete
  12. Hi, Thanks for sharing nice information about Code. Anyone interest to learn Best Digital Marketing Course in Ameerpet . Best institutes is Hyderabad Digital Marketing Institutes they provide all concepts SEO,SMM,SMO ADwords, Affiliate Marketing.

    ReplyDelete
  13. The blog was absolutely fantastic! Lot of information is helpful in some or the other way. Keep updating the blog, looking forward for more content...Great job, keep it up
    Oracle Fusion Financials Online Training
    Oracle Fusion HCM Online Training
    Oracle Fusion SCM Online Training
    oracle Fusion Technical online training

    ReplyDelete
  14. An overwhelming web journal I visit this blog, it's unfathomably amazing. Unusually, in this present blog's substance made inspiration driving truth and reasonable. The substance of data is enlightening
    Oracle Fusion Financials Online Training
    Oracle Fusion HCM Online Training
    An overwhelming web journal I visit this blog, it's unfathomably amazing. Unusually, in this present blog's substance made inspiration driving truth and reasonable. The substance of data is enlightening
    Oracle Fusion Financials Online Training
    Oracle Fusion HCM Online Training
    Oracle Fusion SCM Online Training

    ReplyDelete
  15. I have to voice my passion for your kindness giving support to those people that should have guidance on this important matter.mobile application testing training in bangalore

    ReplyDelete
  16. Thanks for Sharing such an useful and informative content....

    ibm integration bus tutorial

    ReplyDelete
  17. very nice blogs!!! i have to learning for lot of information for this sites...Sharing for wonderful information. Thanks for sharing this valuable information to our vision. You have posted a trust worthy blog keep sharing

    Digital Marketing In Telugu
    Digital Marketing In Hyderabad
    internet marketing
    Digital marketing

    ReplyDelete
  18. wonderful article.thanks for nice information. Our team manages all your social accounts and organized regular engaging social media campaigns so that your business is always creating a buzz on social media.

    digital marketing consultants in chennai | Leading digital marketing agencies in chennai | digital marketing agencies in chennai | Website designers in chennai

    ReplyDelete
  19. thanks for sharing with us,wonderful article.with great blog.River Group of Salon and spa, T.Nagar, provide a wide range of spa treatments, like body massage, scrub, wrap and beauty parlour services. We ensure unique care and quality service.

    massage in T.Nagar | body massage T.Nagar | massage spa in T.Nagar | body massage center in T.Nagar | massage centre in chennai | body massage in chennai | massage spa in chennai | body massage centre in chennai | full body massage in T.Nagar

    ReplyDelete
  20. This is my first time visit to your blog and I am very interested in the articles that you serve. Provide enough knowledge for me. Thank you for sharing useful and don't forget, keep sharing useful info:

    Data Analytics Training in Gurgaon
    DATA ANALYTICS WITH R CERTIFICATION in Gurgaon
    Power Bi Training in Gurgaon

    ReplyDelete
  21. Thanks for sharing this great information I am impressed by the information that you have on this blog. We are providing the best services click on below links to visit our website.
    Oracle Fusion HCM Training
    Workday Training
    Okta Training
    Palo Alto Training
    Adobe Analytics Training

    ReplyDelete
  22. https://www.mindqsystems.com/trainings/angular-js-training-in-hyderabad/
    The angular platform provides flexibility to build mobile and web applications. It is a typescript based web application. Angular allows flexibility to develop applications and reuse code. It also gives maximum flexibility to increase speed and performance via web workers & server rendering. Mind Q Systems offers a complete Angular Training course for students with real-time experience.

    ReplyDelete