开发者

iPhone UITableView with UIImageView

I have created a uitableview with preloaded XML titles and I am looking to add images to the left of the text designed to display videos. This is what I have so far:

// Customize the appearance of table view cells.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

// Get cell
static NSString *CellIdentifier = @"CellA";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
    cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
}

// Display
cell.textLabel.textColor = [UIColor blackColor];
cell.textLabel.font = [UIFont systemFontOfSize:15];
if (item) {

    // Item Info
    NSString *itemTitle = item.title ? [item.title stringByConvertingHTMLToPlainText] : @"[No Title]";

    // Display
    switch (indexPath.section) {
        case SectionHeader: {

            // Header
            switch (indexPath.row) {
                case SectionHeaderTitle:
                    cell.textLabel.font = [UIFont boldSystemFontOfSize:15];
                    cell.textLabel.text = itemTitle;
                    break;
                case SectionHeaderDate:
                    cell.textLabel.text = dateString ? dateString : @"[No Date]";
                    break;
                case SectionHeaderURL:
                    cell.textLabel.text = @"View Full Website";
                    cell.textLabel.textColor = [UIColor blueColor];
                    cell.selectionStyle = UITableViewCellSelectionStyleBlue;
                    break;
                case SectionHeaderEnclosure:
                    cell.textLabel.text = @"Video";
                    cell.textLabel.textColor = [UIColor blackColor];
                    cell.selectionStyle = UITableViewCellSelectionStyleBlue;
                    cell.imageView.image = [UIImage imageNamed:@"MovieFolder.png"];
                    break;
            }
            break;

        }
        case SectionDetail: {

            // Summary
            cell.textL开发者_StackOverflow中文版abel.text = summaryString;
            cell.textLabel.numberOfLines = 0; // Multiline
            break;

        }
    }
}

return cell;

}

I thought I was doing it right, but the image does not show up. What should I do?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜