【发布时间】:2011-12-29 05:22:52
【问题描述】:
我正在尝试使用以下代码使 uiimagview 在 tableviewcell 中具有圆角:
#import <QuartzCore/QuartzCore.h>
(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
HomepwnerItemCell *cell = (HomepwnerItemCell *)[tableView dequeueReusableCellWithIdentifier:@"UITableViewCell"];
Possession *possession = [self.possessions objectAtIndex:indexPath.row];
cell.valueLabel.text = [@"$" stringByAppendingString:[[NSNumber numberWithInt:possession.valueInDollars] stringValue]];
cell.nameLabel.text = possession.possessionName;
UIImage *image = [[ImageCache sharedImageCache] imageForKey:possession.imageKey];
UIImageView *roundedImage = [[UIImageView alloc] initWithImage:image];
roundedImage.layer.masksToBounds = YES;
roundedImage.layer.cornerRadius = 10.0;
cell.imageView = roundedImage;
// cell.imageView.image = [[ImageCache sharedImageCache] imageForKey:possession.imageKey];
return cell;
}
但是当我运行它时,tableViewCells 中的图像显示为空白。
如果我只做cell.imageView.image = [[ImageCache sharedImageCache] imageForKey:possession.imageKey];(但没有圆角)效果很好
我做错了什么?
【问题讨论】:
-
cell.imageView = [roundedImage Image];试试这个。
-
错误:自动引用计数问题:接收器类型“UIImageView”例如消息未声明带有选择器“图像”的方法
-
检查UIImage *image是否分配了内存?
-
除非你没有完整地粘贴上面的方法,你需要先修复你的 tableView:cellForRowAtIndexPath: 代码,然后再担心圆角。如果没有可重复使用的单元格,您将在其中无处分配新单元格??
-
ios5新增:“如果没有可以回收的现有单元格,dequeueReuseableCell会自动制作原型单元格的新副本并返回给您。”
标签: iphone ios cocoa-touch ios5