在表格中显示单元格
-
在项目导航器中,选择
XYZToDoListViewController.m。 -
找到
tableView:cellForRowAtIndexPath:数据源方法。模板实现是这样的:- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{static NSString *CellIdentifier = @"Cell";UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];// Configure the cell...return cell;}
该模板执行多个任务。它会创建一个变量来保存单元格的标识符,向表格视图请求具有该标识符的单元格,添加一个注释注明配置该单元格的代码应该写在哪里,然后返回该单元格。