开发者

iOS - UIViewcontroller detect rotation?

I am using willRotateToInterfaceOrientation to detect rotation and move items according to the orientation.

The problem is that whe开发者_开发技巧n the page first loads this method doesn't get called so it doesn't try to move the objects to the correct location?

What is the solution?


You need to setup the interface according to the orientation

if ([UIDevice currentDevice].orientation == UIDeviceOrientationPortrait)  {
     // do something
} else if ([UIDevice currentDevice].orientation == UIDeviceOrientationLandscapeRight) {
     // do something else
}

And repeat that for al the different device orientations


I manually detected the UIInterfaceOrientation from my UIApplication, and I manually called willAnimateRotationToInterfaceOrientation on viewDidAppear

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜