Search code examples
iosuiscrollviewuitextfielduipicker

UIScrollView makes UITextField stop calling UIPicker


To start off. I have researched this on SO and elsewhere and have not found an exact answer to the problem. I have seen problems similar, but not the same. I have a fully functioning App that uses a picker to populate about 5 textfields. When the user taps on a textfield the picker comes up and everything is great. I recently wanted to expand the space between the textfields to make it look nicer. But I don’t have enough room. So I figured that I could put the textfields into a scrollview and it would be fine. However, when I connect up my action “showYourPicker” the picker no longer comes up, the regular keyboard does. I even tried to make the view a UITextfieldDelegate and run

-(BOOL)textFieldShouldBeginEditing:(UITextField *)textField 
{
[self showYourPicker:self];
return NO;  
}

to show my picker and hide the keyboard, but this doesn’t work. I know that I have hooked up the textfield correctly, because everything goes back to working if I remove the scroll view and hook it all back up. So what do I have to do, to get the picker to show and not the default keyboard when a textfield is inside a scrollview. Thanks in advance. If you need more code, just let me know.


Solution

  • Wherever you are doing this

    UITextField *theTextField = [[UITextField alloc] init];
    

    right after that do this

    textField.inputView = yourPickerView;