更改UITableviewcell中附件类型图标的方法

| 我有表视图,其中显示要下载的文件列表。当我点击附件按钮时,它将下载所选文件。我想更改详细信息披露按钮的图像。可能吗....? 并且如果我在附件视图中将Button与图像一起使用。是否有任何表委托方法用于此...     
已邀请:
        答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];
    
        您可以创建一个UIImageView并将其分配给UITableViewCell \的annexView。
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;
    
        如果要替换默认类型,则可以覆盖UITableViewCell并使用以下代码:
- (void)setAccessoryType:(UITableViewCellAccessoryType)accessoryType
{
    if (accessoryType == UITableViewCellAccessoryDisclosureIndicator)
    {
        self.accessoryView = [[[UIImageView alloc] initWithImage:[UIImage imageNamed:@\"YourNewImage.png\"]] autorelease];
    }
    else
    {
        [super setAccessoryType:accessoryType];
    }
}
    

要回复问题请先登录注册