2013-01-09 3 views
2

보통 내 일반적인 didselectrowatindexpath이처럼 명령없이 선택되지 않은 얻을. 그런 다음 행을 빠르게 선택 해제하십시오. 행을 선택 해제하지 않으면 이전에 선택된 행이 다시있을 때 나타납니다.셀은 선택 해제의

그러나 나는 내 과거의 코드에서 확인하면, 나는 행이 성공적으로 내가 언제 어디서 행을 선택 취소 추적 사방에 함정을 넣어 모든

에서 해제 호출하지 않은 경우에도 해제되는 것을 보았다 :

-(void)viewDidAppear:(BOOL)animated 
{ 

... 

PO(self.tableView.indexPathForSelectedRow); //always show null here 
while(false); 

}

는, viewDidAppear에 의해 밝혀 내가 세부에서 복귀 후 self.tablevView.indexPathForSelectedRow 이미 널 말한다. 행은 이미 선택 취소되었지만 언제 어디서?

나는 사람들의

-(void)tableView:(UITableView *)tableView willDeselectRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    while (false);//breakpoint here never called 
} 

-(void) tableView:(UITableView *)tableView didDeselectRowAtIndexPath:(NSIndexPath *) indexPath 
{ 
    while (false); //breakpoint here never called 
} 

없음 이제까지라고하지 않습니다 명백한 장소에 대한 자세한 트랩을 넣어.

나는 포기했습니다. ,

지금 biggy하지 그러나 이것은 끝이

당신이 거기

UITableViewController의 기본 동작입니다
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    UITableViewCell * cell = [tableView cellForRowAtIndexPath:indexPath]; 

    if ([cell isKindOfClass:[BGUIBusinessCellForDisplay class]]) 
    { 
     BGUIBusinessCellForDisplay * cellBiz = (BGUIBusinessCellForDisplay *) cell; 
     [BGDetailBusinessViewController detailButtonPressed:cellBiz.biz withNavController:self.navigationController]; 
    } 
    else if ([cell isKindOfClass:[BGAddMoreBusiness class]]) 
    { 
     BGBusinessEditViewController * editBusiness = [[BGBusinessEditViewController alloc]init]; 
     [self.navigationController SafelyPushController:editBusiness]; 
    } 
    PO(self.tableView.indexPathForSelectedRow); //not null here 
} 

답변

3

더 desellect 명령이 없음을 확인할 수 있도록이 전체 didSelectRowForIndexPath입니다 날 퍼즐 clearsSelectionOnViewWillAppear의 설명서를 참조하십시오.

이 속성의 기본값은 YES입니다. YES 일 때 테이블보기 컨트롤러는 viewWillAppear: 메시지를 받으면 테이블의 현재 선택을 지 웁니다. 이 속성을 NO으로 설정하면 선택 항목이 유지됩니다.

+0

UITableViewController가 아닌 UIViewController와 함께 tableView를 사용하고 있습니다. –

+0

+1. 내가 무슨 일이 벌어지고 있는지 이미 알고있는 것 같아. –

1

업데이트 : viewWillAppear 행이 선택됩니다. viewDidAppear에 의해 더 이상 존재하지 않습니다. 그들 사이에는 [table reload]이 있습니다. [table reload] 행 선택을 취소합니다.

+0

예,'reloadData'는 선택을 지 웁니다. –