0

I added a PickerView to an TextField, now I want to allow the user to tab on the selected row and then the item must show in the textfield und the pickerView must hide.

I try this but I does not work.

Any help here?

- (void)textFieldDidBeginEditing:(UITextField *)textField {


UIPickerView *pickerViewGeschlecht = [[UIPickerView alloc] init];
pickerViewGeschlecht.dataSource = self;
pickerViewGeschlecht.delegate = self;

UITapGestureRecognizer *myGR = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(pickerTapped:)];
[pickerViewGeschlecht addGestureRecognizer:myGR];

self.txtGeschlecht.inputView = pickerViewGeschlecht;

}

- (void) pickerTapped:(UITapGestureRecognizer*)gestureRecognizer{

txtGeschlecht.text = ausgewaehltesGeschlecht;
}   
Nils
  • 1,469
  • 3
  • 13
  • 17

1 Answers1

0

I am having the same problem. It works great in ios 6.x but it seems like the functional changed in ios 7.x. Now tapping seems to default to picking the row you tapped, and you can no longer set your own tap gesture. There must me a simple Boolean value I have to set, I just can't find it anywhere.

Allowing user to select a UIPickerView row by tapping

This might be how you have to handle the tap now, I like the solution of putting a clear uicontrol over the picker and attaching the tap action to the puckers delegate.

Community
  • 1
  • 1
Popmedic
  • 66
  • 4
  • I had the idea of setting the gesture to the individual view in the picker delegate viewForRow. I can try this when I get home, mobile right now. – Popmedic Jul 22 '14 at 13:25