Domanda

I am currently working though an example in the apple documents but am having a little trouble finding some of the things they are talking about, in particular inside

A Closer Look at Table-View Cells > Loading Custom Table-View Cells From Nib Files

Here

I am not sure about which class needs to be set..

7, Select File’s Owner in the nib document window, open the Identity pane of the inspector, and set the class of File’s Owner to your custom view controller class.

È stato utile?

Soluzione

The owner is your implementation of the table view controller. In your table view controller you define a UITableViewCell property (in this case it is tvCell)

@interface MyTableViewController: UITableViewController {

    IBOutlet UITableViewCell *tvCell;

    @property (nonatomic, retain) IBOutlet UITableViewCell *tvCell;

Then in your nib file for the custom table view cell you specify the files owner as of type MyTableViewController and point the tvCell outlet to the table cell view in the nib.

Then in the cellForRowAtIndex path the following line:

[[NSBundle mainBundle] loadNibNamed:@"TVCell" owner:self options:nil];

this line loads the cells nib, setting your table view controller (i.e. self) as the owner, thus connecting the tvCell property in your table view controller to point to the TableViewCell in the nib.

You can then take a copy of that pointer and initialise the fields in the cell in this method and return that 'custom' cell from the method.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top