Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/27.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 键盘不会隐藏为两个UITextField,其中一个UITextField调用选择器_Ios_Objective C_Keyboard_Uitextfield - Fatal编程技术网

Ios 键盘不会隐藏为两个UITextField,其中一个UITextField调用选择器

Ios 键盘不会隐藏为两个UITextField,其中一个UITextField调用选择器,ios,objective-c,keyboard,uitextfield,Ios,Objective C,Keyboard,Uitextfield,我有两个UITexfield,一个普通,另一个调用我的自定义选择器。问题是,当我在第一个UITextfield中输入文本,然后在第二个UITextfield上点击呼叫选择器后,键盘不会隐藏 我的代码: -(void)textFieldDidBeginEditing:(UITextField *)textField{ if (textField.tag == 5) {//UITextField who call picker [tfNumber resignFirstRe

我有两个UITexfield,一个普通,另一个调用我的自定义选择器。问题是,当我在第一个UITextfield中输入文本,然后在第二个UITextfield上点击呼叫选择器后,键盘不会隐藏

我的代码:

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

    if (textField.tag == 5) {//UITextField who call picker
        [tfNumber resignFirstResponder];
        [tfDate resignFirstResponder];

        datePicker = [[ANDatePickerView alloc]initWithSuperView:self.view delegate:self];
        [datePicker appears];
    } 
}
选择器出现在键盘下方

de问题在哪里?

请尝试以下代码:

     - (BOOL)textFieldShouldBeginEditing:(UITextField *)textField;
        {
          if (textField.tag == 5)
          {
   datePicker = [[ANDatePickerView alloc]initWithSuperView:self.view delegate:self];
        [datePicker appears];
           return NO;

          }
          return YES;
        }

将此行添加到显示pickerView的方法末尾

[self.view endEditing:YES];

请为两个文本字段设置委托。并在下面的方法中设置代码-(BOOL)textField shouldReturn:(UITextField*)textField{//your code}在我将datePicker=[[ANDatePickerView alloc]initWithSuperView:self.view委托:self]放入时有效;[日期选择器出现];在if中