2015-11-10 31 views
1

我正在使用UITableView。我需要有兩個不同的部分,每個部分應該有一個.xib文件。一個xib工作正常,但我無法設法使這兩個工作。令我困惑的是,我無法弄清楚如何在代碼中添加第二個xib的控制器。我很感激你能否告訴我這個邏輯。謝謝。如何將兩個.xib文件添加到兩個不同的部分中

回答

0

它很容易

你可以在一個方法註冊您的筆尖文件:在CellForRow

if (indexpath.section == 0) 
    cell = (CellType1 *)[tableView dequeueReusableCellWithIdentifier:@"CellType1"]; 
else 
    cell = (CellType2 *)[tableView dequeueReusableCellWithIdentifier:@"CellType2"]; 

-(void)registerNibs 
{ 
    [self.tableView registerNib:[UINib nibWithNibName:@"CellType1" bundle:[NSBundle mainBundle]] forCellReuseIdentifier:@"CellType1"]; 
    [self.tableView registerNib:[UINib nibWithNibName:@"CellType2" bundle:[NSBundle mainBundle]] forCellReuseIdentifier:@"CellType2"]; 
} 

和你

相關問題