테이블 뷰에서 첫 번째 셀을 탭하면 didselectrowatindexpath가 트리거되지 않습니다.

StackOverflow https://stackoverflow.com/questions/1487183

문제

테이블 뷰에서 첫 번째 셀을 탭하면 didSelectRowAtIndexPath 트리거되지 않습니까? 내 테이블의 다른 모든 셀은 잘 작동하고 코드에 중단 점을 넣습니다. didSelectRowAtIndexPath 첫 번째 셀이 탭하면 앱이 해당 코드로 들어 가지 않지만 다른 셀이 탭하면 코드로 들어갑니다. 다음은 몇 가지 코드입니다.

    - (NSInteger)tableView:(UITableView *)tableView indentationLevelForRowAtIndexPath:(NSIndexPath *)indexPath
{
    NSInteger row = 0;
    return row;
}

- (NSIndexPath *)tableView:(UITableView *)tableView willSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    NSInteger row = [indexPath row];
    if (row == 0)
        return nil;

    return indexPath;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    //NSUInteger row = [indexPath row];
    //NSString *rowValue = [poolListData objectAtIndex:row];

    int newRow = [indexPath row];
    int oldRow = [lastIndexPathForPoolList row];

    if (newRow != oldRow)
    {
        UITableViewCell *newCell = [tableView cellForRowAtIndexPath:indexPath];
        newCell.accessoryType = UITableViewCellAccessoryCheckmark;

        UITableViewCell *oldCell = [tableView cellForRowAtIndexPath: lastIndexPathForPoolList]; 
        oldCell.accessoryType = UITableViewCellAccessoryNone;

        lastIndexPathForPoolList = indexPath;   
    }

    [tableView deselectRowAtIndexPath:indexPath animated:YES];
}

- (NSInteger)tableViewForDelete:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return [poolListData count];
}

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

    static NSString *DeleteMeCellIdentifier = @"DeleteMeCellIdentifier";

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:DeleteMeCellIdentifier];
    if (cell == nil)
    {
        cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:DeleteMeCellIdentifier] autorelease];
    }

    NSInteger row = [indexPath row];
    cell.text = [self.poolListData objectAtIndex:row];
    return cell;
}

#pragma mark -
#pragma mark Table View Delegate Methods

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 50;
}

- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{   
    NSUInteger row = [indexPath row];
    [self.poolListData removeObjectAtIndex:row];
    [tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
}

시간과 도움이 주셔서 감사합니다.

도움이 되었습니까?

해결책

나는 첫 번째 행에 대해 WillselectrowforIndexPath에서 당신의 반품을 생각합니다. 이렇게하면 행이 선택되지 않습니다.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top