开发者

one image or thumbnail for cells in a table view

i have the following code which will displays result in a UItable view along with an image.

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


    开发者_运维知识库//create a cell
    UITableViewCell *cell = [[UITableViewCell alloc]
                             initWithStyle:UITableViewCellStyleDefault
                             reuseIdentifier:@"cell"];



    // fill it with contnets

    NSDictionary *exercise = [exercises objectAtIndex:indexPath.row];
    cell.textLabel.text = [exercise valueForKey:@"player"];

    UIImage *image = [UIImage imageNamed:@"iphone.gif"];
    cell.imageView.image = image;

    cell.accessoryType = UITableViewCellAccessoryDetailDisclosureButton;

    // return it
    return cell;

}

is there an option where i can display one image for all the cells for ex. 1 image on the left side and then 3 rows by the right side. I am a new bid and still getting my grip on iPhone coding.Please suggest me how we can do this.Thanks.


Yup, a UITableViewCell is pretty much another UIView, so you can add subviews to it and customize it anyway you need. For example, if you need to add an image to all the cells, just add it onto the contentView;

[cell.contentView addSubview:myImageView];

If you have several customizations needed for your cell, and are looking for a highly custom look as opposed to the generic look provided by the standard cells, I'd recommend looking into creating a custom UITableViewCell. The reason is that the standard cells have already laid out UI's with labels, images etc, and anything you add onto it may interfere with the existing UI in ways you do not intend.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜