是的,我已经查看了此错误的所有其他帖子。
这是我的代码:我在哪里错了?
- (UITableViewCell *)TableView:(UITableView *)myTableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [_myTableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
cell.textLabel.text = [_cellArray objectAtIndex: indexPath.row];
return cell;
}
答案 0 :(得分:3)
您的方法名称错误。将TableView
替换为tableView
。为了防止出现这种错误,一旦设置了数据源或委托,就应该使用control + Space,这样Xcode可以通过填写正确的方法名来帮助你。
答案 1 :(得分:1)
问题在于此方法名称:
- (UITableViewCell *)TableView:(UITableView *)myTableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
将其替换为:
- (UITableViewCell *)tableView:(UITableView *)myTableView tableView:(NSIndexPath *)indexPath
实际方法名称为tableView:cellForRowAtIndexPath:
而不是TableView:cellForRowAtIndexPath: