How to hide a UIPickerView when the user make its choice
I'm using a UIPickerView as the inputView for a TextField (thus replacing the onscreen keyboard). I use the following delegate to dismiss the view.
#pragma mark - UIPickerViewDelegate
- (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component {
// Code logic
[[self view] endEditing:YES];
}
Add this line where you have created picker
picker.delegate = self;
your callback
- (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component {
picker.hidden=YES;
}
use the delegate method of UIPickerView
like bellow..
- (void)pickerView:(UIPickerView *)thePickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component {
yourTextField.text = [yourArray objectAtIndex:row];
thePickerView.hidden = YES;
}
Also you can take one UIButton
and hide this with action event of UIButton
.