2013-07-24 2 views
1

코드의 TableView에서 컨트롤러조건부 대상보기 컨트롤러 jQuery과 섹션에서

if ([segue.identifier isEqualToString:@"showListFiles"]) { 

    NSIndexPath *ip = [self.tableView indexPathForSelectedRow]; 

    if (ip.section == 0) { 
     NSDictionary *currentBill = [[_response objectForKey:@"facturas_pendientes"] objectAtIndex:ip.row]; 
     DkBPaymentViewController *pvc = [[DkBPaymentViewController alloc] init]; 
     pvc = (DkBPaymentViewController *) segue.destinationViewController; 
     pvc.setUp = currentBill; 
    } 
    else if(ip.section == 1){ 
     DkBBillsFileTableViewController *ftvc = segue.destinationViewController; 
     ftvc.filesList = [[[_response objectForKey:@"facturas_pagadas"] objectAtIndex:ip.row] objectForKey:@"archivos_facturas"]; 
    } 

} 

오류

-[DkBBillsFileTableViewController setSetUp:]: unrecognized selector sent to instance 0x85a3b00 
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[DkBBillsFileTableViewController setSetUp:]: unrecognized selector sent to instance 0x85a3b00' 

당신이 할 또는 다른보기 조건부 SEGUE하는 가장 좋은 방법은 무엇입니까 수있는 방법 컨트롤러 섹션 (섹션 1 지불/섹션 2 유료) 섹션의 섹션을 기반으로?

세부

DkbPaymentViewController 자신의 XIB을 나는 프로토 타입 셀은 두 개의 서로 다른

DkBBillsFileTableViewController를 가리 키도록 할 수 없습니다 주어진 내가

너무 감사 선언 원래 SEGUE입니다 것있다 훨씬 앞서, 나는 tableview에서 조건부 segue의 좋은 방법을 찾는 것이 모든 사람들에게 도움이 될 것이라고 믿는다.

+0

왜 2 개의 셀과 2 개의 세그먼트가있어 2 개의 다른보기 컨트롤러를 가리키고 있지 않습니까? – Wain

+0

답변을 추가하면 감사하겠습니다. 기꺼이 받아들입니다. –

답변

1

당신은 각각 다른 segues에 설치 2 개 개의 다른 세포를 연결한다 (그래서 그들은 서로 다른 식별자를 가지고)를 각각 다른보기 컨트롤러를 가리키는. 이렇게하면 코드가 간단 해지고 클래스 간의 혼동을 방지하고 의도대로 의도 된 코드를 사용할 수 있습니다.

2

프로그래밍 방식으로 처리 할 수 ​​있습니다. 스토리 보드에서 뷰 컨트롤러 (셀이 아닌)에서 두 개의 단락을 그립니다. 그런 다음 didSelectRowAtIndexPath,이 같은 수행

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    if (indexPath.section == 0) { 
     [self performSegueWithIdentifier:@"SegueForSection1" sender:indexPath]; 
    } else if (indexPath.section == 1) { 
     [self performSegueWithIdentifier:@"SegueForSection2" sender:indexPath]; 
    } 
} 
+0

내 케이스가 다른 경우이 답변을 제공해 주셔서 감사합니다. –

+0

이것은 정확히 내가 찾던 내용이었습니다! 나는 우연히 나를 위해'didDeselectRowAtIndexPath'를 자동 완성하도록했습니다. 그래서 조심하세요. –