2015-04-01 18 views
-1

在我的故事板中,我創建了兩個不同的原型單元格cell1和cell2。我希望他們出現在我的tableView這樣的:在表格視圖中替換兩個不同的自定義單元格佈局

的TableView

prototype cell1 - indexpath.row[0] 
prototype cell2 - indexpath.row[1] 
prototype cell1 - indexpath.row[2] 
prototype cell2 - indexpath.row[3] 
and so on... 

ifswitch語句和for循環試驗中cellForRowAtIndexPath:,但無法得到它的權利。然後我在這裏和互聯網上搜索,但仍然無法找到答案。希望有人能解釋給我?

回答

0

這是簡單的做mod運算符和一個if語句,

if (indexPath.row %2 == 0) { 
    //dequeue cell1 type 
    // configure the cell 
    // return cell 

}else{ 
    //dequeue cell2 type 
    // configure the cell 
    // return cell 
} 
相關問題