Monday, March 07, 2011

UITableView How-To: Part 5 - More About XIB-Based Cells

This post has been moved: click here

3 comments:

Kristjan said...

But is it possible to use the same custom cell for different viewcontrollers in a way that same IBActions in different VC-s get fired when the button is tapped in any of the VC-s?
As far as I understand, it's possible to set only one class for CustomTableCell file's owner.

Brian Slick said...

The specific class of File's Owner doesn't really matter. Any class you choose will have a certain number of IBOutlets and a certain number of IBActions. The cell doesn't have to care about ALL of them, but just the ones you need. If you set the cell up with a particular VC as the File's Owner, and then try to use the cell in another VC, that VC will first try to populate the IBOutlet(s). So as long as that VC has the same IBOutlet(s) that the cell needs, that will be fine. For the IBActions, the XIB is not storing "Call thisMethod: on Class named "Blah"". It is storing "Call thisMethod: on whoever owns this file". So even though you created it with VC#1 in mind, as long as VC#2 has the same IBAction(s), it will be fine. VC#2 will be the owner of the file in that case.

Kristjan said...

Thank you. Really, it worked.