2014-12-29 14 views
0

저는 iOS에서 새롭게 변경되었습니다.오늘 확장 프로그램에 UITableView 추가

오늘 확장 기능을 사용하고 싶습니다. 오늘 확장 기능을 만들고 uitableview를 추가하면 정상적으로 작동합니다. 하지만 행을 선택한 다음 대리자 메서드를 시도 할 때 DidSelectRowAtIndexPath이 호출되지 않습니다.

내 코드에는 3 가지 방법의 uitableview 대리자 및 데이터 소스가 있습니다.

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section 
{ 
    return 3; 
} 

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 
    { 
     UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"MyIdentifier"]; 

if (cell == nil) { 
    cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"MyIdentifier"]; 
} 

cell.textLabel.text = [NSString stringWithFormat:@"Hello World%li",(long)indexPath.row]; 
return cell; 

} 

    - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { 
     return 1; 
    } 

이상 된 데이터 소스 메소드 호출을 제대로

하지만 didselect 행 방법은 행의 선택 호출하지 않습니다.

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath 
    { 
     NSLog(@"row Selected"); 
    } 

감사합니다.

+0

테이블보기 만 스크롤 할 수 있습니까? 더 많은 데이터가 있다면? – Maulik

답변

0

데이터 원본 메서드가 호출됩니다. 그러나 tableView: didSelectRowAtIndexPath:은 데이터 소스 메서드가 아닌 UITableViewDelegate 메서드입니다. 테이블보기의 delegate 속성이 설정되지 않았을 수 있습니다.

0

UITableViewDataSource와 동일한 테이블 뷰 클래스에서 UITableViewDelegate 프로토콜을 구현합니다. didSelectRowAtIndexPath은 정상적으로 작동합니다. 즉, 표의 행을 선택할 때 호출됩니다.

관련 문제