iphone UITableViewCell添加图像

iphone UITableViewCell添加图像,iphone,image,uitableview,Iphone,Image,Uitableview,我有一个子类TableViewController和initWithStyle方法,如: - (id)initWithStyle:(UITableViewStyle)style { self = [super initWithStyle:style]; if (self) { [self.view setFrame:CGRectMake(0, 200, 320, 280)]; } return self; } 我想将背景图像添加

我有一个子类TableViewController和initWithStyle方法,如:

- (id)initWithStyle:(UITableViewStyle)style
{
    self = [super initWithStyle:style];
    if (self) {        
        [self.view setFrame:CGRectMake(0, 200, 320, 280)];
    }
    return self;
} 
我想将背景图像添加到我的每个TableViewCell中,并显示图像,但它只显示了图像的一部分(我的图像大小为320) × 48),我的代码:

结果是:
你可以试试这个

cell.contentView.backgroundColor = [[UIColor alloc] initWithPatternImage:[UIImage imageNamed:@"cell_bg_light.png"]];
或者你可以使用

UIView *cellBackView = [[[UIView alloc] initWithFrame:CGRectZero] autorelease];
cellBackView.backgroundColor = [UIColor colorWithPatternImage: [UIImage imageNamed:@"cell_bg_light.png"]];
cell.backgroundView = cellBackView;

表格单元格分为两部分,第一部分是imageview,第二部分是文本标签。imageview设置在单元格的左侧。你可以参考
UIView *cellBackView = [[[UIView alloc] initWithFrame:CGRectZero] autorelease];
cellBackView.backgroundColor = [UIColor colorWithPatternImage: [UIImage imageNamed:@"cell_bg_light.png"]];
cell.backgroundView = cellBackView;