ios5和6在屏幕的选择方面做了不少的修改。主要是取消了几个api的函数。
– didAnimateFirstHalfOfRotationToInterfaceOrientation: Deprecated in iOS 5.0
– willAnimateFirstHalfOfRotationToInterfaceOrientation:duration: Deprecated in iOS 5.0
– willAnimateSecondHalfOfRotationFromInterfaceOrientation:duration: Deprecated in iOS 5.0
– shouldAutorotateToInterfaceOrientation: Deprecated in iOS 6.0
剩余:
– willRotateToInterfaceOrientation:duration:
– willAnimateRotationToInterfaceOrientation:duration:
– didRotateFromInterfaceOrientation:
剩余这几个函数。平时的项目一般用系统旋转后自动对齐功能,大部分都可以满足需求。这次修改一个项目,tableview在旋转后cell需要加载不同的xib文件,于是重载didRotateFromInterfaceOrientation,不过发现系统并没有调用这个函数。想了一下,估计是tableviewController并不是rootviewControlller。而且是放在其他第三方的ViewController内,估计是第三方ViewController没有使用addChildViewController把tableViewController放入其子controller。查看了一下代码。发现估计是正确的。但是不太想修改这个第三方的ViewController。因为嵌套了2个第三方的ViewController,要修改起来会比较麻烦。
想了想使用注册旋转事件来处理这个需求。
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didRotate:)
name:@"UIDeviceOrientationDidChangeNotification" object:nil];
- (void)didRotate:(NSNotification *)notification
{
NSLog(@"didRotate:。---interFaceOrientation:%d,DeviceOrientation:%d",
self.interfaceOrientation,[[UIDevice currentDevice] orientation]);
//[self.tableView reloadData];
}