在视图控制器中,我添加了一个文本字段,如下所示。
txt1 = [[UITextField alloc]initWithFrame:CGRectMake(10, 10, 70, 20)];
txt1.delegate = self;
txt1.borderStyle = UITextBorderStyleRoundedRect;
[self.view addSubview:txt1];
[txt1 release];
在.h
文件中设置了UITextFieldDelegate
。我写
-(BOOL)textFieldShouldReturn:(UITextField *)textField
为了抹黑我的keyboard.But,它没有触发委托方法。任何帮助!提前谢谢。
发布于 2009-09-21 10:08:28
您尝试发送resignFirstResponder
消息了吗?
- (BOOL)textFieldShouldReturn:(UITextField *)textField {
[textField resignFirstResponder];
return YES;
}
https://stackoverflow.com/questions/1453728
复制相似问题