1

セクションを割り当てた UITableView があります。didSelectRowAtIndex を indexPath.actually と共に使用すると、NSIndexPath パラメータが正しくありません。たとえば、セクション 1 行 0では、indexPath は[0,1]です。 セクション 2 行 0 * 、それは * [0, 2]を取得します。一方、セクション 0 行 1[0, 1]で正しいです。セクション 0 はすべて正しいようです。

私はとてもイライラしていて、理由がわかりませんか?誰かがこれを修正する方法を教えてくれますか、アドバイスをくれますか?

以下はコードです:

- (NSInteger)numberOfSectionsInTableView:(UITableView *)sender 
{
return _store.count;
}

- (NSInteger)tableView:(UITableView *)sender numberOfRowsInSection:(NSInteger)section {

        if ([_store checkIfHasAdditionalContentInSection:section]) {
             return ([_store additionalContentInSection:section].count + 1);
        }
        return 1;
 }

- (UITableViewCell *)tableView:(UITableView *)sender cellForRowAtIndexPath:(NSIndexPath *)indexPath {

    static NSString *CellIdentifier = @"CallLogCell";
    CallLogCell *cell = [sender dequeueReusableCellWithIdentifier:CellIdentifier];
    // Configure the cell...
    if (cell == nil) {
        cell = [[[CallLogCell alloc] initWithStyle:UITableViewCellStyleDefault
                                   reuseIdentifier:CellIdentifier] autorelease];
    }
    CallLog *cLog = [_store itemAtIndex:indexPath];
    cell.callTimes = [_store callTimesAtIndex:indexPath];
    cell.callLog = cLog;
    cell.index = indexPath.section;
    [cell update];

    return cell;
}




- (CGFloat)tableView:(UITableView*)sender heightForRowAtIndexPath:(NSIndexPath*)indexPath{
UITableViewCell *cell=[self tableView:sender cellForRowAtIndexPath:indexPath];
return cell.frame.size.height;
}

#pragma mark - Table view delegate

- (void)tableView:(UITableView *)sender didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
DLog(@"indexPath %@", [indexPath description]);
**//I always get incorrect answer at here**

DLog(@"indexPath section %d row %d", indexPath.section, indexPath.row); 

[sender deselectRowAtIndexPath:indexPath animated:NO];

}
4

1 に答える 1