iPad:如何知道按下iPad键盘的返回键?请检查图像

Dev*_*ang 4 keyboard objective-c ipad ios

我想知道按下以下键时将调用哪个方法.

键盘截图

我想在上面的按键上开始行动.

我怎么知道这是按下的?

Sim*_*Lee 13

观察UIKeyboardDidHideNotification通知.

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardDidHide:) name:UIKeyboardDidHideNotification object:nil];
Run Code Online (Sandbox Code Playgroud)

和...

- (void)keyboardDidHide:(NSNotification *)aNotification {

}
Run Code Online (Sandbox Code Playgroud)

UIKeyboardWillHideNotification如果您需要在键盘开始消失之前收到通知,您也可以将其更改为.


Fil*_*lic 5

那不是返回键.返回键是它上面的那个.这只是一个关闭键盘的按钮,您无法通过标准文本输入法识别它.您需要注册UIKeyboardWillHideNotification通知.

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillHide:) name:UIKeyboardWillHideNotification object:nil];
Run Code Online (Sandbox Code Playgroud)

并实现该方法:

- (void)keyboardWillHide:(NSNotification *)notification
{
    // do whatever you want to do when keyboard dismiss button is tapped
}
Run Code Online (Sandbox Code Playgroud)