views:

29

answers:

3

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?

+1  A: 

@MihaiD

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

arunkumar.p
I've tried with the contentOffset on the UISCrollView but it doesn't make any difference. Besides, why should I mess with the content offset? Everything seem into place in IB...
MihaiD
try to create table programmatically or now ur xib inherit tableview controller class . so change into uiviewcontroller.
arunkumar.p
A: 

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

Alin
Indeed, a UIScrollView is not required. But with a scroll view the user can scroll away from the field he's editing if he wants to.
MihaiD
Then, if the edit field has no focus why there's a keyboard?And really on the subject: did you use the embed in UIScrollView feature of IB when you added the scrollview?
Alin
Well the focus doesn't go away when you tap outside the field. That's pretty much standard behavior from what I see in Apple apps. Yeah I did look at embed but it didn't solve the problem.
MihaiD
+1  A: 

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