cha*_*yWu 3 uiviewcontroller uiview ios
我希望在设备旋转时进行一些布局更改.所以我实现了- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration方法来完成工作.但我意识到这个方法被称为self.view.frame和self.view.bounds是不同的.self.view.bounds.size是正确的,self.view.frame.size似乎仍然没有旋转.
例如,我创建了一个空的singleView项目并实现了如下方法:
- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
{
NSLog(@"willAnimateRotationToInterfaceOrientation");
NSLog(@"self.view.bounds.size width:%f height:%f ",self.view.bounds.size.width,self.view.bounds.size.height);
NSLog(@"self.view.frame.size width:%f height:%f",self.view.frame.size.width,self.view.frame.size.height);
}
Run Code Online (Sandbox Code Playgroud)
当设备从纵向旋转到横向时.输出如下:
2013-06-11 11:57:46.959 viewDemo[95658:707] willAnimateRotationToInterfaceOrientation
2013-06-11 11:57:46.961 viewDemo[95658:707] self.view.bounds.size width:1024.000000 height:748.000000
2013-06-11 11:57:46.961 viewDemo[95658:707] self.view.frame.size width:748.000000 height:1024.000000
Run Code Online (Sandbox Code Playgroud)
我想知道为什么这些尺寸不同?它们不应该总是一样的吗?什么时候选择使用哪一个?
任何帮助将不胜感激.