- Edited your Info.plist to specify allowed orientations
- Make sure you have RootController assigned to your view. Without this auto rotation will not work and you will get a compile time warning - "Application windows are expected to have a root view controller at the end of application launch".
Do the following in AppDeligate.cs
UIWindow window; public override bool FinishedLaunching (UIApplication app, NSDictionary options) { window = new UIWindow (UIScreen.MainScreen.Bounds); // change this to your controller var cvc = new SomeViewController(); window.RootViewController = cvc; // make the window visible window.MakeKeyAndVisible (); return true; }
Once you are done with this, you should get auto-rotation!
Next, you can specify allowed orientations (if you want to limit to a specific set) either in AppDeligate.cs (globally) or in your controller level using the following override:
public override UIInterfaceOrientationMask GetSupportedInterfaceOrientations (UIApplication application, UIWindow forWindow) { return UIInterfaceOrientationMask.Landscape; }Also, on the controller level, you can disable auto rotation all together using the following:
public override bool ShouldAutorotate() { return false; }
Hope this helps! Leave me a comment if this worked for you.
0 comments:
Post a Comment