开发者

Programmatically change view orientation without rotating ipad

开发者 https://www.devze.com 2023-03-27 04:30 出处:网络
I would like to rotate a ViewController based on some condition. The problem with开发者_Python百科 shouldAutorotateToInterfaceOrientation is that the view always start with portrait/landscape orientat

I would like to rotate a ViewController based on some condition. The problem with开发者_Python百科 shouldAutorotateToInterfaceOrientation is that the view always start with portrait/landscape orientation (as set in Interface Builder) and the user has to rotate the ipad to use the correct mode.... How can I change this behavior? Thank you.


Apply a transform to the view.

view.transform = CGAffineTransformMakeRotation(M_PI);

You can use UIView animations to animate the change.


You could also try adding this in your info.plist:

<key>UISupportedInterfaceOrientations</key>
<array>
    <string>UIInterfaceOrientationPortrait</string>
    <string>UIInterfaceOrientationPortraitUpsideDown</string>
    <string>UIInterfaceOrientationLandscapeLeft</string>
    <string>UIInterfaceOrientationLandscapeRight</string>
</array>

Source: ipad default-landscape not displaying


[[UIDevice currentDevice] setOrientation:UIInterfaceOrientationPortrait];

This will change orientation to potrait mode without rotating the device.Likewise you can use for landscape also

0

精彩评论

暂无评论...
验证码 换一张
取 消