简体   繁体   中英

iOS development - How to display static cells created in Interface Builder with custom Table View Controller?

I was trying to display something in static cells with a Table View.

First I create a Table View Controller in interface builder with static cells.

I never designate a custom UITableViewController class, it works well.

But since I designate it to MyTableViewController class, the table view displays nothing.

How to make static cells appear when using a custom UITableViewController class?

In the method:

cellForRowAtIndexPath

you have to get a cell with identifier and then manage it and return it:

static NSString *identifier = @"YourCellIdentifier";

CustomCell *cell = [tableView dequeueReusableCellWithReuseIdentifier:identifier forIndexPath:indexPath];

return cell;

you must set identifier in interface builder..you have to select the cell and write the identifier in the inspector field.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM