[英]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. 首先,我在带有静态单元格的接口构建器中创建一个Table View Controller。
I never designate a custom UITableViewController
class, it works well. 我从不指定自定义
UITableViewController
类,它可以很好地工作。
But since I designate it to MyTableViewController
class, the table view displays nothing. 但是由于我将其指定为
MyTableViewController
类,因此表视图什么也不显示。
How to make static cells appear when using a custom UITableViewController
class? 使用自定义
UITableViewController
类时如何使静态单元格出现?
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. 您必须在接口构建器中设置标识符。.您必须选择单元格并将标识符写入检查器字段。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.