我想在我的UITableView中使用标准公开附件图像的自定义版本。我该怎么做呢?我希望对于如此基础的东西,子类化UITableViewCell不是必需的。
发布于 2008-12-31 19:01:33
您需要创建一个自定义视图,并将其分配给UITableViewCell
对象的accessoryView
属性。类似于:
myCell.accessoryView = [[ UIImageView alloc ]
initWithImage:[UIImage imageNamed:@"Something" ]];
发布于 2010-08-20 12:55:55
- (UITableViewCell *)tableView:(UITableView *)tView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UIImage *indicatorImage = [UIImage imageNamed:@"Arrow.png"];
cell.accessoryView =[[[UIImageView alloc] initWithImage:indicatorImage] autorelease];
return cell;
}
我使用上面给出的帮助代码来做这件事
发布于 2010-01-08 16:08:31
我遇到了与Greg相同的问题--附件视图无法跟踪(如果您使用UIImageView)
我是这样解决的:
UIImage * image = [ UIImage imageNamed:@"disclosure-button-grey.png" ] ;
UIControl * c = [ [ UIControl alloc ] initWithFrame:(CGRect){ CGPointZero, image.size } ] ;
c.layer.contents = (id)image.CGImage ;
[ c addTarget:self action:@selector( accessoryTapped: ) forControlEvents:UIControlEventTouchUpInside ] ;
cell.accessoryView = c ;
[ c release ] ;
https://stackoverflow.com/questions/403748
复制相似问题