Scrolling through UIScrollView in Interface Builde

2019-01-25 02:34发布

This seems to me as though it would be a common problem, but I can't seem to find the answer anywhere. This question seems to address the issue, but I can't seem to get the solution to work and I'm not sure it's referring to Xcode 4.

When using Interface Builder in Xcode 4 and working with a UIScrollView, is there a way to scroll the view down in Interface Builder itself to view/add/edit controls that are out of the viewable section of the screen? I've managed to push a couple controls down using the arrow keys, but now I can't see them and therefore can't manipulate them in Interface Builder. Scrolling the view in IB would be first prize, but if there's a way to even select the controls using a drop-down menu or whatever so I can push them back up with the arrow keys, that would at least be something. Thanks.

7条回答
萌系小妹纸
2楼-- · 2019-01-25 02:49

I know this isn't exactly what you were looking for, but I always just drag the scroll view out of the view controller onto the "pasteboard" where you can resize it at will and see the whole thing.

Once I make my edits I simply resize it to fit it's allotted space in my view and place it back in the view controller.

查看更多
别忘想泡老子
3楼-- · 2019-01-25 03:03

set the root view to freeform and ~1000 pt height, go through the child views and set them to this height as well(including scroll view), in the viewdidload method set the height to the appropriate size.

查看更多
放我归山
4楼-- · 2019-01-25 03:05

I typically do the following when I want to (have to) build a long scrolling screen:

  1. Set the size of the View Controller to Freeform
  2. Set the height of the top level View to something very large
  3. Arrange all the controls that I want on the View
  4. Select all the controls
  5. Select Editor->Embed In->Scroll View
  6. Set the size of the View Controller back to normal (typically Inferred)
查看更多
爷的心禁止访问
5楼-- · 2019-01-25 03:07

Well, there are a few different things you can do. There is a list of items in your view you can open on the left of the workspace by clicking the button that looks like a little play button on the toolbar. Double clicking any item selects it so you can use the arrow keys.

The best option is to use the layout panel (typically on the right) and enter position values manualy. Sometimes I will use this to move my scrollview up to where I can see where I'm working then move it back.

查看更多
地球回转人心会变
6楼-- · 2019-01-25 03:08

Just a workaround which helps in Xcode4:

  1. Expand the Objects Panel which resides on the left of the Interface Builder view (there is the tiny arrow at the bottom of the panel).
  2. Drag your UIScrollView from the view hierachy and place it on the top level.
  3. Now you can resize it to access more content (scrolling to that content did not work for me).
  4. When you are done adding child views to the scrollview, you need to resize it back to be smaller or the same size as the parent view.
  5. After your changes you would need to put back the scroll view where it belongs in your hierachy
查看更多
老娘就宠你
7楼-- · 2019-01-25 03:08

Set the ViewController's Simulated Size to Freeform and set a very large height. E.g: 1000 and voilà! You can now scroll to see all the stuff and add even more! :)

P.S: Remember to set set Fixed when you are finish to avoid problems!

enter image description here

查看更多
登录 后发表回答