【发布时间】:2013-02-28 01:17:45
【问题描述】:
我有一个小问题。我想在 UITableViewCell(在中心)中显示多个(数量是动态的)UIImages。
我该怎么做(UIImages 是通过编程方式生成的)?
非常感谢!
【问题讨论】:
标签: ios uiimage center tableviewcell
我有一个小问题。我想在 UITableViewCell(在中心)中显示多个(数量是动态的)UIImages。
我该怎么做(UIImages 是通过编程方式生成的)?
非常感谢!
【问题讨论】:
标签: ios uiimage center tableviewcell
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
NSString *CellIdentifier = [NSString stringWithFormat:@"S%1dR%1d",indexPath.section,indexPath.row];
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if(cell == nil)
{
cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
cell.selectionStyle = UITableViewCellSelectionStyleNone;
self.imgThings = [[UIImageView alloc] init];
// imgThings.backgroundColor= [UIColor magentaColor];
[self.imgThings setImage: [UIImage imageNamed:@"image.png"]];
self.imgThings.center = CGPointMake(cell.contentView.bounds.size.width/2,cell.contentView.bounds.size.height/2);
[cell.contentView addSubview:self.imgThings];
}
return cell;
}
以上只是一张图片的简单示例,您也可以通过更改图片名称来设置多张图片。
【讨论】: