使用UITableViewController
我总是通过界面进行操作(见下面的截图)
现在,如果我使用UIViewController
这是我的代码
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
NSString *messageAtIndexPath = [messageArray objectAtIndex :[indexPath row]];
[[cell textLabel] setText:messageAtIndexPath];
return cell;
}
请咨询
除非我添加一个混乱我的界面的原型单元格。
答案 0 :(得分:1)
这里有几件事:
1)UITableViewController 从UIViewController继承(我认为这是你实际谈论的,而不是“UIControllerView”)。 UITableViewControllers能够执行原型单元格并设置这些标识符......
2)... 区分大小写 。在屏幕截图中,您将其称为“cell
”,而在代码中将其称为“Cell
”。
它们需要拼写完全相同并且采用相同的大/小写方式。
你在这里尝试做什么并不是很清楚,但我觉得你想在你的XIB或故事板中创建一个自定义单元格,然后用你的“cellForRowAtIndexPath:
”方法引用它。 Here is a tutorial that talks about prototype cells and identifiers and using them in storyboards,我希望这会帮助你。