I have a UIPickerView that appears when a textfield is selected:
-(void) showPicker
{
[self.genere resignFirstResponder];
pickerGenero = [[UIPickerView alloc] initWithFrame:CGRectMake(0,215,320,0)];
pickerGenero.delegate = self;
pickerGenero.dataSource = self;
pickerGenero.showsSelectionIndicator = YES;
[self.parentViewController.tabBarController.view addSubview:pickerGenero];
pickerGenero=nil;
}
- (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component
{
return [genreArray count];
}
- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView {
return 1;
}
- (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component
{
self.genere.text =[genreArray objectAtIndex:row];
[self.pickerGenero removeFromSuperview];
}
But is not removed when a row is selected. Textfield is updated with the selected value, but the picker view is not removed. I’ve tried to use as a trial .sethideen=True but it doesn’t work, too.
Many thanks
Actually your’s is not the correct way of coding. When you click the textField you just hide the keyboard by using
resignFirstResponderand invokingpickerView.Instead of doing like that, you have to add yourpickerViewasinputViewforgeneretextField. and try this code then