0
我有TableViewController的一个子类,并initWithStyle方法,如:iphone UITableViewCell中添加图像
- (id)initWithStyle:(UITableViewStyle)style
{
self = [super initWithStyle:style];
if (self) {
[self.view setFrame:CGRectMake(0, 200, 320, 280)];
}
return self;
}
我想背景图片添加到我的每一个TableViewCell,并显示图像,但它只是显示的图像的一部分(我的图像尺寸为320×48),我的代码:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}
cell.imageView.image = [UIImage imageNamed:@"cell_bg_light.png"];
return cell;
}
和结果:
非常感谢你,你是对的,但为什么呢? – Gaojian922188
表格单元格分为两部分,第一部分是imageview和第二部分文本标签。 –
imageview设置在单元格的左侧。你可以参考http://developer.apple.com/library/IOS/#documentation/UIKit/Reference/UITableViewCell_Class/Reference/Reference.html –