2013-05-13 2 views
0

나는 자신을 재귀 적으로 n 번 호출하는 UITableViewController 있습니다재귀있는 UITableViewController 및 대표

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    if (indexPath.section == 0) { 
     // call different controller 
    } 
    else if (indexPath.section == 1) { 
     GroupTableViewController *tableView = [[GroupTableViewController alloc] initWithStyle:UITableViewStyleGrouped]; 
     tableView.delegate = self; 

     [self.navigationController pushViewController:tableView animated:TRUE]; 
    } 
} 

내가 현재 GroupTableViewController에 새로운 GroupTableViewController의 대리자를 설정해야합니다.

Assigning to `id<GroupTableViewDelegate>' from incompatiable type `GroupTableViewController *const_strong` 

그래서 내 첫번째 생각은 GroupTableViewDelegate 프로토콜을 포함했다 : 나는 코드에서와 같이 대리자를 설정하려고하면

, 내가 경고를

@interface GroupTableViewController : UITableViewController <RegionTableViewDelegate, GroupTableViewDelegate> 

을 그러나 이것은 원인 경고 :

Cannot find protocal definition for `GroupTableViewDelegate` 

하지만

하려고하면
#import "GroupTableViewController.h" 

문제가 발생할 수 있습니다.

어떻게하면됩니까? 여기

GroupTableViewController *tableView = 
    [[GroupTableViewController alloc] initWithStyle:UITableViewStyleGrouped]; 

tableViewUITableView 인스턴스에 대한 포인터 여기

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

tableView됩니다

이름을 변경해야 GroupTableViewController 인스턴스에 대한 포인터 -

답변

1

코드는 약간의 혼란 명확성을위한이 하나 :

GroupTableViewController *gtViewController = 
    [[GroupTableViewController alloc] initWithStyle:UITableViewStyleGrouped]; 

그러면 오류가 분명 해져야합니다.

이 : 이름

tableView.delegate = self; 

이 있습니다 :

gtViewController.delegate = self; 

당신이 정말로 원하는 것은 :

gtViewController.tableView.delegate = self; 

추가 프로토콜을 위임 선언 엉망 필요가 없습니다 .. .

+0

좋아, 나는 th 전자 컨트롤러, 불행히도 그것은 경고를 해결하지 못했습니다. 아직 가지고있어. – Padin215

+0

@ Log139,'controller.delegate = self'도'controller.tableView.delegate = self'로 변경 했습니까? – foundry

+0

아, 아니에요. 전체 게시물을 읽지 못해 죄송합니다. 나는 그것을 훑어 보았고 내가 무엇을해야할지 알았다고 생각했다. 분명히 나는하지 않았다. 고맙습니다, 그 경고를 분명히했습니다. – Padin215