2012-06-19 4 views
0

테이블 뷰를 배우려고하고 있는데 걸렸습니다. Storyboard에 뷰 대리자와 데이터 소스가 올바르게 연결되어 있지만 테이블 뷰가 포함 된 응용 프로그램 섹션에 도달하면 다음 런타임 오류가 발생합니다. 당신의 CraftingViewController 클래스는 아마 유형 UITableViewController의처럼 보인다 동안Xcode TableView - 인스턴스로 전송 된 인식 할 수없는 셀렉터

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UINavigationItem tableView:numberOfRowsInSection:]: unrecognized selector sent to instance 

여기 내 구현 파일

@implementation CraftingViewController 

- (void)viewDidLoad 
{ 
    [super viewDidLoad]; 
    // Do any additional setup after loading the view. 
} 


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

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    static NSString *CellIdentifier = @"Cell"; 

    UITableViewCell *cell = (UITableViewCell *) [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; 

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

    cell.textLabel.text = @"Detail"; 

    return cell; 

} 

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

} 

답변

1

tableView:numberOfRowsInSection:이 유형 UINavigationItem의 객체에 전송되고 있기 때문 오류 메시지가 표시됩니다의 덩어리입니다. CraftingViewController이 제대로 연결되어 있지 않기 때문에 대리자를 올바른 클래스에 연결했는지 확인해야합니다.

+0

감사합니다, 그것은 내가의 ViewController가 아닌 네비게이션 컨트롤러에 연결된 테이블보기를했다 판명이 컨트롤러 사용 "CraftingViewController"없다 "의 UIViewController"의 ALLOC를 확인하세요 – Alex

-1

데이터 소스가 nib 파일의 컨트롤러 인 경우.

관련 문제