尝试这个,
假设您有一个简单的横向模式 iphone 应用程序,例如一个简单的视图控制器应用程序。
也像这样取消注释 viewcontroller .m 文件中的自动旋转
-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
NSLOG(@"width:%f,height:%f",self.view.frame.size.width,self.view.frame.size.height);
return YES;
}
之后,只需在 iphone 模拟器上运行这个东西,然后尝试通过 command+left 或 command+right 旋转它。
我希望在纵向和横向模式下会得到类似 width:320.000,height:480.000 和 width:480.000,height:320.000 的东西。
相反,我总是得到宽度:320.000,高度:480.000 实际方向是什么。
所以我的问题是我应该如何自动正确获取视图的大小?