2017-01-24 5 views
0

그래서 2 개의 사용자 정의 셀이있는 테이블 뷰를 만들었습니다.여러 개의 TableView 사용자 정의 셀

제 3의 셀에 데이터를 입력하려고하는데, 제 3의 셀에서 얼마나 많은 셀을 반환 할 때 &도 제 제목 배열을 시작하는 데 문제가 있습니다. 마지막 경우

func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { 
     return 3 
} 

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { 

    var row = indexPath.row 

    if(row == sliderIndex){ 

     var cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath) as! Row 

     return cell 

    }else if (row == instagramIndex) { 

     var cell2 = tableView.dequeueReusableCell(withIdentifier: "instgramCell", for: indexPath) as! Insta 

     return cell2 

    } else { 

     var cell3 = tableView.dequeueReusableCell(withIdentifier: "blogCell", for: indexPath) as! blogCell 

     if (row == 3) { 

      cell3.blogTitle.text = titleArray[0] 

     }      
     return cell3 
    } 
+0

수 나는'sliderIndex = 0'과'instagramIndex = 1'을 추측 했는가? 그런 다음'numberOfRows'는'titleArray.count + 2'와 같고'else'의 경우'cell3.blogTitle.text = titleArray [row-3]'또는 그와 비슷한 것 (+ 1 또는 -1. – Larme

답변

0

은 행 당신은 func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) 3을 반환 2.

로 변경이 동일한 것은 불가능합니다. 그래서 행의 값은 [0, 1, 2]

것 그리고 당신의 코드에 따라, 당신은 그들이 0이어야한다 2. instagramIndex를 1로 sliderIndex을 설정하고 설정 실수로 1