2013-11-28 5 views
-3

5 개의 셀이있는 표가 있는데 사용자가 두 번째 셀을 클릭하면 다른 표나 다른 페이지를 표시하려고합니다.didSelectRowAtIndexPath 사용


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

방법을 사용?

+0

예, 셀의 클릭 수를 감지하는 데 사용합니다. – joao

+0

감사합니다. 그 간단한 예를 들어 주시겠습니까? – kpsaravan

답변

0

http://www.tutorialspoint.com/ios/ios_ui_elements_tableview.htm은 제 2 셀에 대한 사용자 클릭 수 (만약 탐색 컨트롤러를 가정) 다른 뷰 컨트롤러 탐색의 예 스토리 보드를 사용하는 경우 tableView:didSelectRowAtIndexPath:을 건너 뛰고 대신 prepareForSegue:sender:을 사용할 수 있습니다.

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { 
    if ([segue.identifier isEqualToString:@"__SEGUE_IDENTIFIER__"]) { 
     NSIndexPath *indexPath = [self.tableView indexPathForSelectedRow]; 

     SomeOtherViewController *vc = (SomeOtherViewController *)segue.destinationViewController; 
      // assign something to vc 
    } 
} 
0

샘플 링크 :

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

    if(indexPath.row == 1){ 

     MyViewController * vc = [[MyViewController alloc] init]; 
     [self.navigationController pushViewController:vc animated:YES]; 

    } 

} 
0

경우 : 여기

if (indexPath.row ==1) 

{ 

      //Second cell index path its move another class xib 

    classname *yourcontroller = [[classname alloc] initWithNibName:@"xib file name" bundle:nil]; 

    yourcontroller.modalTransitionStyle = UIModalTransitionStyleCoverVertical; 
    [self presentViewController:helpcontroller animated:YES completion:nil]; 

} 
관련 문제