我尝试用不同的 UITableViewCells 填充我的 UITableView。我试图通过标识符从 XIB 文件中选择 3 个 UITableViewCells 中的 1 个,但我无法获得 UITableViewCell 标识符的值。
- (UITableViewCell *)tableView:(UITableView *)_tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
MyTableViewCell *cell = (MyTableViewCell *) [tableView dequeueReusableCellWithIdentifier:@"CellTwo"];
if(nil == cell){
NSArray *topLevelObjects = [[NSBundle mainBundle] loadNibNamed:@"MyTableViewCell" owner:self options:nil];
for (id currentObject in topLevelObjects) {
if ([currentObject isKindOfClass:[MyTableViewCell class]]) {
MyTableViewCell *tmpCell = (MyTableViewCell *) currentObject;
if (tmpCell.identifier == @"CellTwo") {
cell = (MyTableViewCell *) currentObject;
}
[tmpCell release];
break;
}
}
}
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
return cell;}