2014-04-04 1 views
-1

내가보기로드 후 처음으로 내 jQuery과에 탭, 나는 두 번째로 두 드릴jQuery과 이상한 행동

- (void)tableView:(UITableView *)tableView didDeselectRowAtIndexPath:(NSIndexPath *)indexPath{ 

    NSLog(@"the clicked index -- %i", indexPath.row); 
} 

에서 어떤 출력을 얻을 - 이후의 모든 탭은 - 내가 기대하는 출력을 얻을 이전 탭에서 (동일한 행을 탭하지 않는 한 물론 메시지를 트리거하지 않습니다.) 내가 행 다음 2, 0을 누릅니다 그렇다면, 내가 출력을 얻을 다음 하나

  • 아무것도 여기
  • 2
  • 1

cellForRowAtIndexPath에 대한 코드를;

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

    static NSString *CellIdentifier = @"Cell"; 

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; 
    if (cell == nil) { 
     cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier]; 
    } 

    [cell setSelectionStyle:UITableViewCellSelectionStyleNone]; 
    [cell setBackgroundColor:[UIColor blueColor]]; 
    [cell.textLabel setTextColor:[UIColor whiteColor]]; 
    [cell.textLabel setTextAlignment:NSTextAlignmentCenter]; 

    if (_currentTileIndex >= 0 && _currentTileIndex < _timeSlotChumsArrays.count) { 

     cell.textLabel.text = (NSString*)_timeSlotChumsArrays[_currentTileIndex][indexPath.row]; 

    } 

    return cell; 
} 

실마리가 있습니까?

+0

넣어 cellForRowAtIndexPath 방법 코드에 ... – iPatel

+0

검사는 tableview에 –

+1

당신의 slected 인덱스를 얻을 것이다 대답의 나 잘못된 위임자를 사용하고 있습니다. didDeselect는 셀이 선택 해제 될 때 호출됩니다. 이것은 매우 일반적인 실수입니다. UITableView로 작업하는 동안 대부분의 사람들과 함께 발생합니다. – ZeMoon

답변

2

잘못된 대리인 메서드를 사용하고 있습니다. 셀 선택을 취소하면 -didDeselect가 호출됩니다.

변경

- (void)tableView:(UITableView *)tableView didDeselectRowAtIndexPath:(NSIndexPath *)indexPath 

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath 
0

사용이 대리자 메서드

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    NSLog(@"%i", indexPath.row); 
}