0

私のcellForRowコードには次のものがあり、何も返されていないというエラーが表示されます。私は何を間違えましたか?ありがとう。

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    UITableViewCell* cell = [tableView cellForRowAtIndexPath:indexPath];
    if([self.checkedIndexPath isEqual:indexPath]) 
    { 
        cell.accessoryType = UITableViewCellAccessoryCheckmark;
    } 
    else
    { 
        cell.accessoryType = UITableViewCellAccessoryNone;
    } 
    return cell;
}
4

2 に答える 2

3

これは無限ループです:UITableViewCell* cell = [tableView cellForRowAtIndexPath:indexPath];

これは次のようになります。

static NSString *reuseIdentifier = @"some_identifier";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:reuseIdentifier];
if(cell == nil) {
    cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:reuseIdentifier] autorelease]
}
于 2012-07-17T19:30:26.103 に答える
0

あなたcellForRowAtIndexPathはこのようになります(最も基本的なテーブルビューの場合)

- (UITableViewCell *) tableView :(UITableView *) tableView cellForRowAtIndexPath :(NSIndexPath *) indexPath
{
    static NSString *SimpleTableIdentifier = @"SimpleTableIdentifier ";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:SimpleTableIdentifier];
    if (cell == nil) {
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault 
                                       reuseIdentifier:SimpleTableIdentifier] autorelease];
    }

    NSUInteger row = [indexPath row];
    cell.textLabel.text = [listData objectAtIndex :row];
    cell.textLabel.font = [UIFont boldSystemFontOfSize:50];

    return cell;
}
于 2012-07-19T05:41:17.550 に答える