2012-12-21 3 views
1

특정보기 컨트롤러에서 테이블의 모든 테이블 셀에 대한 작업입니다. 다른 셀에 대해 다른 Segue를 사용하고 싶다면 셀을 구분하는 가장 좋은 방법은 무엇입니까? 당신이 비슷한 작업을 수행 할 수 있습니다다른 테이블보기 셀에 대한 자세한 내용

+0

당신은 자세한 내용을 추가 할 수 있습니다 적이있다? 나는 당신이 무엇을하려고하는지 확신하지 못한다. –

+0

내가 다른 5 개의 -6 개의 다른 Segues를 가지고있다. "테이블보기 셀을위한 다른 Disclosure 버튼들과 연결하고 싶다. 그러나 위의 코드는 모든 셀에서 작동하고있다. 셀을 구별 할 수 있습니다. –

답변

0

,

- (void)tableView:(UITableView *)tableView accessoryButtonTappedForRowWithIndexPath:(NSIndexPath *)indexPath 
{ 
    if (indexPath.row == 0) 
    [self performSegueWithIdentifier:@"YourSegueIdentifierHere" sender:self]; 
    else if (indexPath.row == 1) 
    [self performSegueWithIdentifier:@"YourSecondSegueIdentifierHere" sender:self]; 
    else if (indexPath.row == 2) 
    [self performSegueWithIdentifier:@"YourThirdSegueIdentifierHere" sender:self]; 
} 

또는이 경우도 switch (indexPath.row) 선택할 수 있습니다.

indexPath은 각 셀마다 고유하며 다른 섹션의 다른 셀을 구별하는 데 indexPath.rowindexPath.section을 사용할 수 있습니다.

+1

굉장 :) if ((indexPath.row == 9) && (indexPath.section == 1)) –

0

나는 그것을 사용하거나 테스트하지만 이러한 방법은 간단한 스위치 케이스를 존재하거나/다른 블록이 충분히 될 경우 내가 생각하는 경우

- (void)tableView:(UITableView *)tableView accessoryButtonTappedForRowWithIndexPath:  (NSIndexPath *)indexPath 
{ 
    switch (indexPath.row) { 
    case 0: 
    { 
     [self performSegueWithIdentifier:@"YourSegue1" sender:self]; 
     break; 
    } 
    case 1: 
    { 
     [self performSegueWithIdentifier:@"YourSegue2" sender:self]; 
     break; 
    } 
    case 2: 
    { 
     [self performSegueWithIdentifier:@"YourSegue3" sender:self]; 
     break; 
    } 
    default: 
     break; 
}  

} 
관련 문제