How do I rotate the iOS simulator using code?

前端 未结 2 1869
生来不讨喜
生来不讨喜 2021-01-05 22:18

Does anyone know how to rotate the iOS Simulator (6.0 and above)? I\'ve searched but have found nothing on this.

I am trying to do this through code (not manually),

2条回答
  •  暖寄归人
    2021-01-05 22:37

    Well there are couple of steps you have to check to make all orientations work in iOS6. Even if one of them is missing it won't work.

    1. As Lance says, yes you have to set the supported orientations for iphone or ipad whatever appropriate.

    2. Write this code in the controller which you want to set the rotation for.

      -(NSUInteger)supportedInterfaceOrientations { return UIInterfaceOrientationMaskAll; }

      -(BOOL)shouldAutorotate { return YES; }

    Change UIInterfaceOrientationMaskAll depending on what orientations you want.

    1. If you are using a navigation controller in your project make sure you set it properly!

    You shouldn't be getting this error...(Applications are expected to have a root view controller at the end of application launch)

    Get these steps right and rotation will work for you.

提交回复
热议问题