2009-09-28 4 views
2

내 테이블 뷰의 첫 번째 셀을 누르면 didSelectRowAtIndexPath이 트리거되지 않습니다. 아무도 보이지 않거나 왜 이런 일이 발생했는지에 대한 단서가 있습니까? 내 테이블의 다른 모든 셀을 잘 작동하고 내 코드에서 중단 점을 넣을 didSelectRowAtIndexPath 첫 번째 셀을 두드리는 경우 응용 프로그램이 해당 코드로 이동하지 않지만 다른 셀이 두드린 경우 코드로 이동합니다.내 tableview의 첫 번째 셀을 누르면 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]; 
} 

이 시간 내 주셔서 감사하고 도움이 당신이 내게 줄 수 : 여기에 몇 가지 코드입니다!

+0

엉망으로 미안합니다 ... 코드를 붙여 넣을 수없는 것 같습니다. – Jeff

+0

수정되었습니다. 풀리스트 초기화를위한 lastindexpath는 어디에 있습니까? – ennuikiller

+0

당신은 tableview.delegate를 설치 했습니까? – CiNN

답변

3

첫 번째 행의 willSelectRowForIndexPath에서 반환 값이 0이라고 생각합니다. 이렇게하면 행이 선택되지 않습니다.

+0

도착 방법 !!! 나는 그것을 꺼내서 이제 첫 번째 행을 선택할 수 있지만, 다른 행을 먼저 선택한 후에 만 ​​!! 고맙습니다!! – Jeff

관련 문제