1

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.

Douglas
  • 2,524
  • 3
  • 29
  • 44
  • have you set the inputView property of the textField to be your picker? That'd be the right way to do it. – Nitin Alabur Jan 14 '13 at 19:36
  • @calvinBhai. Yes, I set that in the method showYourPicker. It works in all the other tabs of the app, except the one I have put the scroll view in. Should I set the property elsewhere? Thanks. – Douglas Jan 14 '13 at 21:02
  • ideally, you should do your textField.inputView = yourPickerView; when the textfield is created or added to the view. – Nitin Alabur Jan 14 '13 at 21:11
  • So maybe in the view will appear or view did load? – Douglas Jan 14 '13 at 21:14
  • yup, wherever you do your UITextField *theTextField = [[UITextField alloc] init];, right after that – Nitin Alabur Jan 14 '13 at 21:29
  • I'll give it a try! Thanks, I will let you know how it goes. – Douglas Jan 14 '13 at 22:17
  • @calvinBhai, YES!!! Thank you so much. Can you post your comment as an answer. It worked! I moved all my "creating the picker and determining the input view" to the view did load method and it all works fine. Thanks so much. – Douglas Jan 15 '13 at 00:58

1 Answers1

0

Wherever you are doing this

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

right after that do this

textField.inputView = yourPickerView;
Nitin Alabur
  • 5,812
  • 1
  • 34
  • 52