如何为以编程方式创建的文本字段触发textFieldDidEndEditing函数

时间:2012-08-14 17:28:40

标签: ios5 uitextfield keyboard-events

以下是我正在编写的代码

UITextField *category =[[UITextField alloc] initWithFrame:CGRectMake(10, 90, subView.frame.size.width-15, 30)];
category.backgroundColor=[UIColor whiteColor];
category.placeholder = @"Category, Description, Model (optional)";
category.returnKeyType = UIReturnKeyNext;
// [category addTarget:self action:@selector(textFeild) forControlEvents:<#(UIControlEvents)#>]

该语句应该是什么,以便我可以添加textFieldDidEndEditing控件事件?

1 个答案:

答案 0 :(得分:1)

UITextField的委托设置为自己

category.delegate = self;

确保创建UITextField的类实现UITextFieldDelegate