2012-07-22 74 views
1

我有一個UITableView和許多具有不同表格視圖樣式的.xibs。每個.xib都有自己的類,並根據該部分註冊了重用標識符。例如: 在我viewDidLoad中我有以下幾點:更改CellReuseIdentifier基於部分

UINib *cellStyleOne = [UINib nibWithNibName:@"CellStyleOne" bundle:nil]; 
[self.tableView registerNib:cellStyleOne forCellReuseIdentifier:@"CellStyleOne"]; 

UINib *cellStyleTwo = [UINib nibWithNibName:@"CellStyleTwo" bundle:nil]; 
[self.tableView registerNib:cellStyleTwo forCellReuseIdentifier:@"CellStyleTwo"]; 

UINib *cellStyleThree = [UINib nibWithNibName:@"CellStyleThree" bundle:nil]; 
[self.tableView registerNib:cellStyleThree forCellReuseIdentifier:@"CellStyleThree"]; 

我將如何分配這些重用標識符之一在我的cellForRowAtIndexPath細胞的部分,而不會造成任何問題?

謝謝。

回答

1

你可以返回你裏面cellForRowAtIndexPath:喜歡的任何細胞,只是像做

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    if (indexPath.section == 0) 
    { 
     //create and return a cell with reuse ID: @"CellStyleOne" 
    } 
    else 
    { 
     //create and return a cell using a different reuse ID 
    } 
}