Screwtape
Screwtape

Reputation: 1367

How do I get an event message from UITextField in a custom table cell to the table cell?

I'm sure this is a very noddy question, but I just can't get anything useful from the manuals.

I've a UITextField embedded in a custom UITableViewCell. If I use a delegate for the UITextView - it just gives me the UITextView.

If I link the event to the ParerentViewController, it just gives me the ID of the UITextView.

What I want to do is handle the event at the UITableViewCell level. Can I get the events from this text control to feed to the parent, and handle them at the parent level.

I don't seem to even be able to find the parent cell from the UITextField that the handler gives me. How do I find out which cell within the table the UITextField is in when I'm trying to process the events.

I have to be missing something obvious, as I've done this in earlier (pre storyboard) versions, and I'm sure it wasn't this difficult.

Upvotes: 1

Views: 73

Answers (2)

ShahiM
ShahiM

Reputation: 3268

Create a subclass of UITableViewCell and implement the textField delegates inside the subclass. The code is lengthy but if you want I can post it when I get time.

Upvotes: 1

Rory McKinnel
Rory McKinnel

Reputation: 8014

Answered a similar question the other day. See the accepted answer.

How can I get index path of cell on switch change event in section based table view

This will let you handle the text changes in the cell and pass them on to the table view. In your case its a UITextView and not a UISwitch.

Add properties to the cell for anything you will need inside the block code when it is called.

Upvotes: 1

Related Questions