我的应用程序运行在iOS 8上,当旋转应用程序时,我需要更改UI。
目前,我正在使用以下代码:
-(BOOL)shouldAutorotate
{
UIDeviceOrientation orientation = [[UIDevice currentDevice] orientation];
if (orientation != UIInterfaceOrientationUnknown) [self resetTabBar];
return YES;
}
我的做法是移除当前的用户界面并添加一个适合方向的新界面。但是,我的问题是每次进行一次旋转时,这种方法都会被调用约4次。
在iOS 8中,如何正确地在屏幕方向改变时进行更改?