2012-07-22 70 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 
    } 
}