Re: UITableViewCell with UITextField


Alex Zavatone
 

On Sep 26, 2018, at 9:41 AM, Gerriet M. Denkmann <g@mdenkmann.de> wrote:



On 26 Sep 2018, at 20:21, Alex Zavatone via Groups.Io <zav=mac.com@groups.io> wrote:

Try adding nonatomic and strong to your property.

@property (nonatomic, strong) IBOutlet UITextField *textField;

Also, did you set the XIB in the storyboard to your subclass and drag the UITextField to your property?
I found a solution without an extra xib file: just using a Prototype Cell in the tableView.

Class: MyTableViewCell
Style: Custom
Identifier: “Cell with TextField”

The Prototype Cell has in its Connections Inspector an Outlet named “textField”;
Control-Drag from the empty circle at the right to the UITextField.
Yeah, that’s what I meant by making the class of the XIB to be your class and making the identifier your identifier. Granted, I probably wasn’t super clear at that time of the morning. That control dragging was what I meant by “wire up”.

This Control-Dragging from the Connections Inspector was a new trick (for me). Took me a while to find this.
Yeah, the control dragging is SUPER non-intiutive, ESPECIALLY when considering that it will not work if you try and drag from the storyboard item over to empty circle next to your property - even though that is the thing that changes its appearance once it is connected. : /

You have to drag over the name of the property for the connection to stick.

Knowing how long someone can spend trying to determine how to do this, I’m sorry I wasn’t able to be clearer.


The reason I opt to use XIBs for this is that if you are working on a team where many people will have their hands in the storyboard, this removes the potential of any merge conflicts and that’s just one less thing to worry about.

Glad that it works for you in any case and happy to help.

Cheers,
Alex Zavatone

Join cocoa@apple-dev.groups.io to automatically receive all group messages.