我的控制器中有一个UITableView
。细胞为UITableView
有xib。由于某种原因,加载表格时,单元格的视图被隐藏。
我可以选择单元格,我看到单元格不是零,视图也不是零,仍然隐藏了单元格。
这是代码:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath: (NSIndexPath *)indexPath
{
NSString *cellIdentifier = @"CategoryCell";
CategoryCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
if (cell == nil){
NSArray* topObjects = [[NSBundle mainBundle] loadNibNamed:cellIdentifier owner:self options:nil];
for (id obj in topObjects){
if ([obj isKindOfClass:[CategoryCell class]]){
cell = (CategoryCell*)obj;
}
}
}
id object;
if (indexPath.row < items.count)
object = [items objectAtIndex:indexPath.row];
if ([object isKindOfClass:[MenuCategory class]]) {
// Configure the cell
MenuCategory *cellInfo = (MenuCategory *)object;
[cell setCategory:cellInfo];
}
else if([object isKindOfClass:[MenuSubCategory class]]){
// Configure the cell
MenuSubCategory *cellInfo = [self.items objectAtIndex:indexPath.row];
[cell setSubCategory:cellInfo];
}
return cell;
}