Resigning First Responder for multiple UITextField

2019-03-15 06:18发布

There is an application in which I am generating multiple UITextFields dynamically. I want to resign first responder whenever the UITextFields are not selected (touch outside the UITextField). How can I know that of which UITextField I have to resign first responder? Please specify any other way beyond the 'tag' concept because I have tried that. Please suggest the right direction. Thanks in advance.

13条回答
神经病院院长
2楼-- · 2019-03-15 07:20

The most generic way and also the only one that worked for me in an UITableViewController was sending the action down the responder-chain and wait for the right object to receive the action:

[[UIApplication sharedApplication] sendAction:@selector(resignFirstResponder) to:nil from:nil forEvent:nil];

Tested in iOS8

查看更多
登录 后发表回答