UITableViewCell没有显示它的内容

时间:2014-04-14 20:41:06

标签: ios objective-c uitableview

我正在使用带有动态TableView的UITableViewController,它显示有关菜肴的一些信息。一切都工作正常,但一个单元格保持空白。

当我调试代码时,所有东西看起来都像预期的那样(tableView:cellForRowAtIndexPath:为self.menuItem.menuPortions中的每个部分调用,部分isn&n =&n;并且它的属性值是有效的, UILabels也没有,但是第一部分Cell仍然是空的,无论self.menuItem.menuPortions有多少部分......

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    UITableViewCell *cell;

    switch (indexPath.section) {
        case 0:{//image
            cell = [tableView dequeueReusableCellWithIdentifier:@"imageCell" forIndexPath:indexPath];
            UIImageView* imageView = ((UIImageView*)[cell viewWithTag:1]);
            [self.menuItem setImageOfImageView:imageView OrDeleteCellAtIndexPath:indexPath fromTable:tableView];
            break;}
        case 1:{//description
            cell = [tableView dequeueReusableCellWithIdentifier:@"descriptionCell" forIndexPath:indexPath];
            UITextView * descriptionTextView = (UITextView*)[cell viewWithTag:1];
            descriptionTextView.text = self.menuItem.menuItemDescription;
            break;}
        case 2:{//portions
            cell = [tableView dequeueReusableCellWithIdentifier:@"portionCell" forIndexPath:indexPath];
            id<MenuItemPortionProtocol> portion = self.menuItem.menuPortions[indexPath.row];

            UILabel * sizeLabel = (UILabel*)[cell viewWithTag:1];
            sizeLabel.text = portion.size;

            UILabel * priceLabel = (UILabel*)[cell viewWithTag:2];
            priceLabel.text = [portion priceString];
            break;}
        case 3:{//categories
            cell = [tableView dequeueReusableCellWithIdentifier:@"categoriesCell" forIndexPath:indexPath];
            UILabel* categoriesLabel = (UILabel*)[cell viewWithTag:1];
            categoriesLabel.text = [self.menuItem.categories componentsJoinedByString:@", "];
            break;}
        default:
            break;
    }

    // Configure the cell...
    return cell;
}

有人有提示,出了什么问题吗?

0 个答案:

没有答案