Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I set the delegate for a text field in the interface builder to "files owner"?

I am trying to implement the :

- (BOOL) textFieldShouldReturn:(UITextField *)textField

method. For some reason it is not being called. I have set the text field to first responder in the code. I understand I also need to set the delegate for the text field in interface builder to 'files owner'. How do that? Thank you!

like image 522
Kex Avatar asked Jan 11 '15 15:01

Kex


2 Answers

If you have declared your UITextField as an IBOutlet property, you can just add the following line in your viewDidLoad: self.myTextField.delegate = self

Alternatively, you can do it in Storyboards.

enter image description here

like image 137
nburk Avatar answered Nov 20 '22 13:11

nburk


You can right click drag from the text field on the interface builder canvas to the File's Owner icon in the object list on the left.

Or you can select the text field, open the outlet inspector, drag from the little circle next to delegate over to the File's Owner icon in the object list.

Or you can right click drag from the text field icon in the object list to the same File's Owner icon in that list.

Or you can set the delegate in code.

like image 6
Andrew Monshizadeh Avatar answered Nov 20 '22 14:11

Andrew Monshizadeh