-1

是的,我已经查看了所有其他出现此错误的帖子。

这是我的代码:我在哪里出错了?

- (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;
}
4

2 回答 2

3

您的方法名称错误。替换TableViewtableView。为防止此类错误,一旦您设置了数据源或委托,您应该使用 control + Space,这样 Xcode 可以通过填写正确的方法名称来帮助您。

于 2013-04-30T17:13:16.237 回答
1

问题在于此方法名称:

- (UITableViewCell *)TableView:(UITableView *)myTableView cellForRowAtIndexPath:(NSIndexPath *)indexPath

将其替换为:

- (UITableViewCell *)tableView:(UITableView *)myTableView tableView:(NSIndexPath *)indexPath

实际的方法名tableView:cellForRowAtIndexPath:不是 TableView:cellForRowAtIndexPath:

于 2013-04-30T17:04:33.670 回答