简体   繁体   中英

How to hide UIPickerView in uitextfield?

I created a UITextField and I set this inputview a pickerview. If I click into the textfield the pickerview is showing, but if I don't want to change the pickerview value, I tried to click on the view to dismiss pickerview, but its not working... I set textfield inputview in viewDidLoad():

picker = [[UIPickerView alloc] init];
picker.dataSource = self;
picker.delegate = self;
self.pickerTF.inputView = picker;

pickerTF is an UITextfield and picker is an UIPickerView.

I tried to use these methods to dismiss pickerview:

-(BOOL)textFieldShouldReturn:(UITextField *)textField{
[textField resignFirstResponder];
return true;
}
-(BOOL)disablesAutomaticKeyboardDismissal{
return NO;
}

I have already edited .h file:

@interface MyViewController : UIViewController <UIPickerViewDataSource, UIPickerViewDelegate, NetworkManagerDelegate, UITextFieldDelegate>

将轻endEditing:手势识别器添加到文本字段的超级视图, endEditing:在超级视图上调用endEditing:

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM