Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UiTextField events

When I create UITextField inside Interface Builder, I can access Events tab for it, which has events like Value changed, Touch cancel, Touch drag, etc. I can assign my own methods to every of those events. How can I do the same, when I create UITextField programmatically with alloc?

like image 819
Mike Avatar asked Apr 07 '10 16:04

Mike


1 Answers

Refer to Apple documentation for UIControl. After initializing your textField, call addTarget:action:forControlEvents:

example for the touch event ending an edit session

[textField addTarget:self action:@selector(handleTouchValueChanged:) forControlEvents: UIControlEventEditingDidEnd]
like image 76
falconcreek Avatar answered Nov 01 '22 01:11

falconcreek