How to set device (UI) orientation programmatically?

后端 未结 10 1529
感情败类
感情败类 2020-11-30 01:14

Would like everything on the screen (UI) to be able to rotate from landscape left to right or vica versa.

How do I go about doing this? Is this private?

I

10条回答
  •  暖寄归人
    2020-11-30 01:59

    This was addressed by: Guntis Treulands https://stackoverflow.com/a/10146270/894671

    //-----------------------------------
    // FORCE PORTRAIT CODE
    //-----------------------------------
    [[UIApplication sharedApplication] setStatusBarOrientation:UIDeviceOrientationPortrait animated:NO];
    //present/dismiss viewcontroller in order to activate rotating.
    UIViewController *mVC = [[UIViewController alloc] init];
    [self presentModalViewController:mVC animated:NO];
    [self dismissModalViewControllerAnimated:NO];
    

提交回复
热议问题