我有表视图,显示要下载的文件列表。当我点击附件按钮时,它将下载所选文件。我想改变细节披露按钮的图像。有可能......?
如果我在附件视图中使用Button和图像。是否有任何表委托方法...
答案 0 :(得分:4)
答案2:你可以制定自己的方法并在那种情况下调用它。
int row=indexPath.row;
UIButton *trackImageOnMap=[[UIButton alloc] initWithFrame:CGRectMake(420, 9, 40, 50)];
[trackImageOnMap setImage:[UIImage imageNamed:@"track_map_icon.png"] forState:UIControlStateNormal];
int iId=[[self.imageId objectAtIndex:row] intValue];
NSLog(@"iId=%d",iId);
[trackImageOnMap setTag:iId];
[trackImageOnMap addTarget:self action:@selector(trackImageOnMapButtonTouched:)forControlEvents:UIControlEventTouchDown];
[trackImageOnMap setContentMode:UIViewContentModeScaleToFill];
//[cell setAccessoryView:trackImageOnMap];
[cell addSubview:trackImageOnMap];
答案 1 :(得分:3)
您可以创建一个UIImageView并将其分配给UITableViewCell的accessoryView。
UIImageView *imageView = [[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"accessoryIcon"]] autorelease];
cell.accessoryView = imageView;
如果你想要一个配件按钮,它基本上是相同的:
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
[button setImage:[UIImage imageNamed:@"buttonImage"] forState:UIControlStateNormal];
[button addTarget:self action:@selector(someAction:) forControlEvents:UIControlEventTouchUpInside];
button.tag = cell.indexPath;
cell.accessoryView = button;
答案 2 :(得分:0)
如果要替换默认类型,可以覆盖UITableViewCell并使用以下代码:
- (void)setAccessoryType:(UITableViewCellAccessoryType)accessoryType
{
if (accessoryType == UITableViewCellAccessoryDisclosureIndicator)
{
self.accessoryView = [[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"YourNewImage.png"]] autorelease];
}
else
{
[super setAccessoryType:accessoryType];
}
}