我在设置UIImageView或UIView对iPhone上分组表格的单元格时遇到问题。将UIImageView或UIView添加到分组表格的单元格
为了这个,我用这个代码
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *SimpleTableIdentifier = @"SimpleTableIdentifier";
NSArray *listData =[self.tableContents objectForKey:[self.sotreKeys objectAtIndex:[indexPath section]]];
UITableViewCell * cell = [tableView
dequeueReusableCellWithIdentifier:SimpleTableIdentifier];
if(cell == nil) {
cell = [[[UITableViewCell alloc]
initWithStyle:UITableViewCellStyleDefault
reuseIdentifier:SimpleTableIdentifier] autorelease];
}
if(indexPath.section == 1 && indexPath.row ==1)
{
UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(240, 14, 40, 40)];
imageView.image = [UIImage imageNamed:[NSString stringWithFormat:@"Back.png",nil]];
[cell.contentView addSubview:imageView];
[imageView release];
}
NSUInteger row = [indexPath row];
cell.textLabel.text = [listData objectAtIndex:row];
return cell;
[tableView deselectRowAtIndexPath:indexPath animated:YES];
}
但它不是放置在细胞。当我选择只显示那一行的行时,会出现什么问题?
有没有人有任何想法是什么问题。我认为图像被细胞覆盖。
在此先感谢
仔细检查 “Back.png” 确实存在于您的项目资源 –
此外,使用[ImageView的setBackgroundColor:[的UIColor redColor];这实际上将帮助你看看莫名其妙图像是不可见由于细胞/表背景颜色 –
@joe是你有任何想法在添加图像onthe细胞我在我的应用程序分组表视图是问题。 – Ajay