I Have an a touchesEnded event that checks for when a UITextField is pressed. What I would like it to do is is hide/show a UIPickerView. How can this be done?
Below is the sample code to hide and show of UIPickerView
with animation:-
//For Displaying
-(void)showPickerView{
self.pickerSheet = [UIAlertController alertControllerWithTitle:@"Select font" message:nil preferredStyle:UIAlertControllerStyleActionSheet];
self.pickerView = [[UIPickerView alloc]initWithFrame:CGRectZero];
self.pickerView.dataSource = self;
self.pickerView.delegate = self;
self.pickerView.showsSelectionIndicator = YES;
[self.pickerView selectRow:1 inComponent:0 animated:YES];
[self.pickerSheet.view addSubview:self.pickerView];
self.pickerView.translatesAutoresizingMaskIntoConstraints = NO;
UIView *view = self.pickerView;
[self.pickerSheet.view addConstraints:[NSLayoutConstraint
constraintsWithVisualFormat:@"V:|[view]|"
options:0l
metrics:nil
views:NSDictionaryOfVariableBindings(view)]];
[self.pickerSheet.view addConstraints:[NSLayoutConstraint
constraintsWithVisualFormat:@"H:|[view]|"
options:0l
metrics:nil
views:NSDictionaryOfVariableBindings(view)]];
[self presentViewController:self.pickerSheet animated:YES completion:^{
}];
}
//For hiding
-(void)hidePickerView{
[self.pickerSheet dismissViewControllerAnimated:YES completion:^{
}];
}