我希望能够在用户触摸屏幕键盘上的返回时立即发送消息。我有一个发送 UIButton,如何让它监听返回键? 谢谢!
最佳答案
你的按钮方法:
- (void) btnPressed:(id)sender {
{
如果还没有,请添加代理内容
@interface YourViewController : UIViewController <UITextFieldDelegate>
当您调用 textField 时:
yourTextField.delegate = self;
然后,您应该只在委托(delegate) shouldReturn
方法中调用按钮的操作方法:
- (BOOL) textFieldShouldReturn:(UITextField *)textField {
[self btnPressed:nil];
// whatever else you need
return YES;
}
关于ios - 如何在用户点击键盘上返回时单击 UIButton,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22668503/