简体   繁体   English

故事板编辑器布局混乱

[英]Storyboard editor layout confusion

I am having layout problems with the storyboard editor with a fairly simple screen. 我在屏幕相当简单的情节提要编辑器中遇到布局问题。 I have a UIViewController to which I have added a 320x440 UIScrollView at 0,0 followed by a 320x20 UIProgressBar at 0,440. 我有一个UIViewController,在0,0处添加了320x440 UIScrollView,然后在0,440处添加了320x20 UIProgressBar。 It looks fine in Storyboard editor. 在Storyboard编辑器中看起来还不错。 I'm not entirely sure how the 20 pixel status bar at the top of the screen is accommodated given the CGRect frame coordinates that Storyboard calculates. 考虑到Storyboard计算的CGRect帧坐标,我不确定如何容纳屏幕顶部的20像素状态栏。

On loading ( in -(void)viewDidLoad ), the UIScrollView frame seems to be set to 320x460 pixels at 0,0 but the UIProgressBar is still 320x20 at 0,440. 加载时(在-(void)viewDidLoad ),似乎将UIScrollView帧设置为0,0时为320x460像素,但UIProgressBar仍为0,440时为320x20。

When I add subviews to the UIScrollView, (UIImageViews in particular), they get stretched and get clipped on the screen because although the UIScrollView thinks it is 460 pixels high, it only has 440 pixels of screen to display in. 当我将子视图添加到UIScrollView(尤其是UIImageViews)时,它们会被拉伸并在屏幕上被剪切,因为尽管UIScrollView认为它的高度为460像素,但只能显示440像素的屏幕。

Can anyone point me to a solution? 谁能指出我的解决方案?

Thanks 谢谢

OK - I have identified what was going on - there were a number of issues, nearly all to do with mutually incompatible settings in storyboard attributes on various view controllers. 好的-我已经确定发生了什么-存在很多问题,几乎都是与各种视图控制器上的故事板属性中相互不兼容的设置有关。

In summary, the main view controller containing the UIScrollView had the 'wants full screen' checkbox ticked - goodness knows how, but it appears that I had then gone through other views trying to compensate for that initial error by clipping, resizing, setting layout constraints etc. which resulted in rather confusing outcomes. 总而言之,包含UIScrollView的主视图控制器已选中“想要全屏显示”复选框-天哪知道,但是我似乎经过了其他视图,试图通过裁剪,调整大小,设置布局约束来补偿该初始错误。等导致了令人困惑的结果。

My advice would be to not touch ANYTHING in storyboard editor unless you know what it's effect will be - it is a dangerous place. 我的建议是不要在情节提要编辑器中接触任何东西,除非您知道它的作用是什么-这是一个危险的地方。 I found the issue by going back to basics and creating a trivially simple replication of my app and then observing the differences between that app and my own. 通过回到基础知识并创建我的应用程序的简单复制,然后观察该应用程序与我自己的应用程序之间的差异,我发现了问题。 Sorry if I wasted anybody's time researching an answer. 抱歉,如果我浪费任何人研究答案的时间。

Thanks 谢谢

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM