我的视图尺寸错误。我仅运行横向,但视图报告纵向尺寸“视图宽度 = 768.000000 高度 = 1024.000000” 有任何想法如何解决这个问题吗?我尝试过使用自动旋转
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return (interfaceOrientation == UIInterfaceOrientationLandscapeLeft|| interfaceOrientation == UIInterfaceOrientationLandscapeRight);
}
and
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return YES;
}
它在视图上看起来不错,但尺寸确实对我的应用程序造成了干扰。
你永远不应该使用frame
告诉你自己的维度。frame
是相对于父容器视图的。要查找相对于视图自身坐标系的尺寸,请使用bounds
: self.view.bounds
例如,父视图可能会看到宽度 = 768 和高度 = 1024 的子视图,但具有旋转 90 度变换。这就是父视图看到子视图的方式,这就是self.view.frame
是关于。宽度 = 1024 和高度 = 768 的子视图通过视图在自己的坐标系中如何看待自身来反映,即self.view.bounds
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)