开发者

how do i work on a taller view in interface builder?

开发者 https://www.devze.com 2023-01-27 04:01 出处:网络
OK, so I am learning to use UIScrollView in interface builder.since the scrollView itself does not have any content, I created another view, the contentView, to hold my controls and scrollable content

OK, so I am learning to use UIScrollView in interface builder. since the scrollView itself does not have any content, I created another view, the contentView, to hold my controls and scrollable content. into this view I place controls, labels, etc and then in my code i set the contentSize of the scrollView to the size of this contentView.

My question seems stunningly simple and so obvious that I must have missed something somewhere. when I created this XIB in I开发者_如何学运维B I got your standard empty iPhone interface window. I dropped a scrollView on top of it, it took up the whole window. I dropped a view on top of that, it took up the whole scrollview. I added some controls, which so far I can still see inside the contentView rectangle in IB.

My question is how do I work on/add controls which lie outside of the visible part of the contentView in IB? LOL. it seems so simple, but i just don't get it. I can set the height of the content view or drag the rectangle to whatever I like (and indeed this is the whole point of having a scrollview) but the fixed UI window from IB won't expand so i can see the "offscreen" part of the contentView to add more controls. It's like it's just fixed at that size because that's the size of one iPhone screen and it won't let me make it any bigger/taller.

what did I do wrong?

-a


You need to turn off all simulated user interface elements (like the status bar) to be "undefined" except for size, which you select to be "Freeform" from the drop-down, and then you can set the view height using the Ruler tab to be whatever you like.

For example, here I've selected a photo view controller, and set the size in the right side bar to be "iPad Full Screen" - but I could also change that to "freeform" to set any height I wished.

how do i work on a taller view in interface builder?

how do i work on a taller view in interface builder?


First add a ViewController by any which way you prefer. Then in interface builder, click on the view controller Icon (on left). In the connections inspector click on the ruler icon "Show the size inspector". There will be option list for simulated size, change to "Freeform" and increase the height to any size you want. Hope this helps.


neeever mind. you drag the content view up so that some controls are offscreen and then add more controls/expand to the part you just made visible by moving the top stuff off the top. in effect, you physically scroll the contentView in IB by dragging it with the mouse. seems a smidge counterintuitive, but whatever.


Set simulated size to freeform for the the view controller to a large enough size that you can add in your controls

how do i work on a taller view in interface builder?


You don't have to create a view to place inside the scrollview if you don't want. In your case, it sounds like it doesn't make much sense.

As for the second part of your question, you can place items directly on the scrollview (it is a view afterall), as subviews. If you want them to be off screen, then just set their frame up to be at those particular x, y coordinates you want it to be at. You will have to ensure your scrollview's contentSize property is large enough though to house your entire content, this is what allows scrolling horizontally/vertically.


You probably want to do the offscreen elements programmaticly instead of using xibs.

0

精彩评论

暂无评论...
验证码 换一张
取 消