开发者

Moving and existing UI on a UIScrollView

开发者 https://www.devze.com 2023-01-22 07:01 出处:网络
I have some xibs with all sorts of text controls (UITextFields, UITextViews). Since the keyboard obscures some of these text controls when text input starts, I followed Apple\'s guideline for managing

I have some xibs with all sorts of text controls (UITextFields, UITextViews). Since the keyboard obscures some of these text controls when text input starts, I followed Apple's guideline for managing content located under the keyboard.

In short, the solution involves moving all interface elements on a UIScrollView. Doing it from Interface Builder I simply add a UIScrollView on the view, make it the size of the view, send it to back and link it's referencing outlet to the file's owner view property.

In IB this all looks fine, and the UI elements appear above the UIScrollView. However when I run the program, the UI elements are nowhere to be found. Their IBOutlets however seem to get initialized so it looks like they are actually constructed. I've tried to set the UIScrollView alpha to 0 to see if they are placed behind it but I still can't find them. New items that are added to the UIScrollView however, seem to work fine.

This leaves me with the not so great option of rebuilding all my xibs where I need to开发者_如何学运维 do this change. It kind of looks like an Interface Builder bug to me. What do you guys think?


Well I've found a solution. It goes like this:

  1. Drag a UISCrollView in IB's main window (where we have the File's Owner and First Responder objects).
  2. Rescale it to the size of the initial view
  3. Drag and drop everything from the original view to the scroll view.
  4. Link the scroll view's referencing outlet to the file's owner view property.
  5. Delete the old view from IB's main window.


@MihaiD

use tableview.contentOffset=CGPointMake(x,y);


I don't know if you really need a UIScrollView. See this question on SO it slides the parent view up.

0

精彩评论

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