我有一个故事板1 UIViewController
,持有1 UIView
,其中包含一些嵌套UIView
s。我子类的视图控制器实现此方法:UIView在横向上有纵向尺寸吗?
- (BOOL)shouldAutorotateToInterfaceOrientation: UIInterfaceOrientation)interfaceOrientation {
return (interfaceOrientation == UIInterfaceOrientationLandscapeRight || interfaceOrientation == UIInterfaceOrientationLandscapeLeft);
}
我还添加了
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>UIInterfaceOrientation</key>
<string>UIInterfaceOrientationLandscapeLeft</string>
到Info.plist
。
在主要的UIView的viewDidLoad中我这样做:
的问题是控制仅仅是756px宽,而不是预期的1024参见下面的截图了解详情。 我一直在网上搜索,但我无法找到解决这个令人沮丧的问题的任何地方。我使用Xcode 4.5和iOS5.1作为基础SDK。
编辑 它的工作方式是用边界替换帧。但我不明白发生了什么,所以它不适用于帧大小。
谢谢!用界限代替“框架”是可行的!但是,我不明白为什么?任何机会使它与框架一起工作?不明白为什么UIView的大小在超视图和它自己的坐标系统中有所不同 – s1m0n 2012-07-09 16:14:03
根据我的理解,这是因为视图位于窗口上,并且该窗口必须具有内部横向模式,如果这种模式在某种程度上接近于如果窗口与其视图一起旋转并且它是子视图,则窗口坐标系中的视图坐标不反映旋转。你可能想要刷新坐标系知识以便更好地理解(旋转和可能的转换必须足够用于这种情况):http://en.wikipedia.org/wiki/Cartesian_coordinate_system这是我记得的一个学校数学。 – 2012-07-09 22:53:54
这可能是值得通过http://stackoverflow.com/questions/1210047/iphone-development-whats-the-difference-between-the-frame-and-the-bounds,和一些相关的问题。 – 2012-07-10 15:01:50