Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/date/2.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 如何在没有第一响应者的情况下关闭输入字段_Ios_Objective C_Swift_First Responder - Fatal编程技术网

Ios 如何在没有第一响应者的情况下关闭输入字段

Ios 如何在没有第一响应者的情况下关闭输入字段,ios,objective-c,swift,first-responder,Ios,Objective C,Swift,First Responder,我在一个viewController上,textField是第一个响应者,然后在某个回调方法上实例化一个视图,但在实例化的viewController上键盘仍然打开,我试图通过[self.view endEditing:YES]关闭键盘,但它不起作用。使用viewController的默认越界功能 override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) { view.endEditin

我在一个viewController上,textField是第一个响应者,然后在某个回调方法上实例化一个视图,但在实例化的viewController上键盘仍然打开,我试图通过
[self.view endEditing:YES]
关闭键盘,但它不起作用。

使用viewController的默认越界功能

override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
    view.endEditing(true)
}
override func touchsbegind(touch:Set,带有事件:UIEvent?){
view.endEditing(真)
}

使用viewcontroller的默认覆盖功能

override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
    view.endEditing(true)
}
override func touchsbegind(touch:Set,带有事件:UIEvent?){
view.endEditing(真)
}

尝试在ViewDidDemouse中添加[self.view endEditing:YES]

尝试在ViewDidDemouse中添加[self.view endEditing:YES]

hi go to MainstryBoard,如果它与您的MainstryBoard相同,只需选中自动启用返回键上的复选标记,然后返回代码

/// the method where  view is getting instantialte before view get Instantite use this here is sample.

  [self resignKeyBoard];


您好,转到MainstryBoard,只需检查auto enable returnkey上的复选标记(如果它与您的MainstryBoard相同),然后返回您的代码

/// the method where  view is getting instantialte before view get Instantite use this here is sample.

  [self resignKeyBoard];