how to resignFirstResponder from view controller

2019-01-26 22:38发布

How to resignFirstResponder from uiviewcontroller object with is active.

I have five textfields one,two,three,four,five.

   - (void)removeKeyBoard{
     [one resignFirstResponder];
     [two resignFirstResponder];
     [three resignFirstResponder];
     [four resignFirstResponder];
     [five resignFirstResponder];
    }

The above code has done my job, but each object reference to specify for resignFirstResponder.

Is there any way, that handle the resignFirstResponser which ever field is active on UIViewController automatically resign that object.

@All Thanks in advance.

2条回答
虎瘦雄心在
2楼-- · 2019-01-26 23:13
- (void)textFieldDidEndEditing:(UITextField *)textField {
    [textField resignFirstResponder];
}
查看更多
放我归山
3楼-- · 2019-01-26 23:18

Called on whatever view has the textfields in it:

[view endEditing:YES]

UIView reference: Link

查看更多
登录 后发表回答