简体   繁体   中英

iOS - UIViewcontroller detect rotation?

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

The problem is that when 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

我手动检测UIInterfaceOrientation从我UIApplication ,我叫手动willAnimateRotationToInterfaceOrientationviewDidAppear

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM