2014-10-23 3 views
0

한 테이블 뷰가 정적 인 동안 단일 뷰 컨트롤러에서 2 개의 tableview를 갖기 위해 노력 중이며 다른 동적 인 동안.단일 스토리 보드에서 여러 테이블보기

은 내보기 제어기 그래서 enter image description here

tableview에 고정되는 상부 반 같이 설정된다.

나는 두 tableViews에 대한 ibOutlets를 만들었지 만 테이블을 사용자 지정할 수없는 것처럼 보입니다. [: forIndexPath : jQuery과 dequeueReusableCellWithIdentifier] /SourceCache/UIKit_Sim/UIKit-3318.16.14/UITableView.m:6116 2014년 10월 23일 22시 31분 -

override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { 

    let cell = tableView.dequeueReusableCellWithIdentifier("cell2", forIndexPath: indexPath) as UITableViewCell 

    //tableview2 is the dynamic tableView. 
    if (tableView == self.tableView2){ 
     print("Tableview2") 

    } 
    else{ 
     println("HELLLO") 
    } 




    return cell 
} 

제가 오류 * 어설 실패를 얻을 : 52.246 Recipe app [2857 : 504809] * 캐치되지 않은 예외 'NSInternalInconsistencyException'으로 인해 앱 종료 중, 이유 : '식별자 cell2의 셀을 큐에서 제거 할 수 없습니다. 식별자의 펜촉이나 클래스를 등록하거나 스토리 보드 '.

답변

1

오류가 발생하면 "식별자의 신분증이나 클래스를 등록하거나 스토리 보드에 프로토 타입 셀을 연결해야합니다"라고 말합니다.

viewDidLoad 또는 awakeFromNib에서이 작업을 수행하십시오.

self.tableView.registerClass(UITableViewCell.classForCoder(), forCellReuseIdentifier:"cell2") 

또는 당신은 "CELL2"식별자 당신이 동적 테이블 reuseIdentifier "CELL2"에 대한 프로토 타입 셀을 준 가정

enter image description here

0

, 이동을 스토리 보드에 프로토 타입 세포를 만들고 그것을 제공해야 이 줄을 다음 if ... 절, 또는 else ... 절 중 하나에

let cell = tableView.dequeueReusableCellWithIdentifier("cell2", forIndexPath: indexPath) as UITableViewCell 

(whiche ver는 동적 테이블을 다룹니다). tableView가 정적 테이블 인 경우 오류가 발생합니다.

관련 문제