我想在按下键盘返回键时调用一个功能,我想在iPad上按下键盘隐藏键时调用另一个功能..所以我需要检查是否按了返回键还是按下了隐藏键.. < / p>
答案 0 :(得分:0)
您可以使用UITextField委托方法检查ex ...
//Managing Editing
– textFieldShouldBeginEditing:
– textFieldDidBeginEditing:
– textFieldShouldEndEditing:
– textFieldDidEndEditing:
//Editing the Text Field’s Text
– textField:shouldChangeCharactersInRange:replacementString:
– textFieldShouldClear:
– textFieldShouldReturn:
- textFieldShouldReturn:方法仅在用户单击键盘中的返回按钮时调用。当用户点击隐藏键时,它不会调用...你可以检查。
<强>更新强>
使用键盘通知:
- UIKeyboardWillShowNotification
- UIKeyboardDidShowNotification
- UIKeyboardWillHideNotification
- UIKeyboardDidHideNotification
- UIKeyboardWillChangeFrameNotification
- UIKeyboardDidChangeFrameNotification
用于&#34; UIKeyboardWillHideNotification&#34;。所以刚刚实施:
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(KeyboardWillHide:) name:UIKeyboardWillHideNotification object:nil];
希望这有帮助。