-
resignFirstResponder 这种方式都需要知道对应的编辑控件才能调用
响应:becomeFirstResponder
关闭:resignFirstResponder -
在视图控制器里面调用
[self.view endEditing:YES];
- 在视图控制器获取困难的时候用,在视图控制器里面也能用
[[UIApplication sharedApplication] sendAction:@selector(resignFirstResponder) to:nil from:nil forEvent:nil];
- 和上面一样,view结束editing
[[[UIApplication sharedApplication] keyWindow] endEditing:YES];
本文详细介绍了在Swift中如何使用becomeFirstResponder和resignFirstResponder方法来管理UI控件的编辑状态。通过在视图控制器中调用[self.view endEditing:YES]或使用UIApplication的sendAction方法,可以有效地控制编辑状态的开启与关闭。此外,还提供了通过UIWindow结束编辑的另一种方式。
10万+

被折叠的 条评论
为什么被折叠?



