当用户点击一个表视图(表UIButton视图在每一行中有多个按钮)时,会显示另一个视图。在用户单击另一个 UIView 的完成按钮后,我想更改此按钮的图像。我怎样才能做到这一点?我是新手。你能为我提供一些代码吗?提前致谢。
更新代码:
表格视图代码:
    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    NSString *CellIdentifier = [NSString stringWithFormat:@"%d,%d",indexPath.section,indexPath.row];
    UITableViewCell *cell = [_tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil)
    {
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
        UIButton *market = [UIButton buttonWithType:UIButtonTypeCustom];
        [market addTarget:self action:@selector(marketPressedAction:) forControlEvents:UIControlEventTouchDown];
        [market setTag:3000];
        [market setFrame:CGRectMake(200, 6, 30, 30)];
        [cell.contentView addSubview:market];
    }
   for (UIButton *button in [cell subviews]) { // change name of table here
    if ([button isKindOfClass:[UIButton class]]) {
        button.tag = indexPath.row;
        [button setImage:[UIImage imageNamed:@"Marketplace.png"] forState:UIControlStateNormal];
    }
}
    cell.accessoryType = UITableViewCellAccessoryDetailDisclosureButton;
    _tableView.contentInset = UIEdgeInsetsMake(0, 0, 100, 0);
    return cell;
}
打开按钮的代码(用户单击以显示另一个视图的按钮)
    - (void)marketPressedAction:(id)sender
{
    UIButton *button = (UIButton *)sender;
    buttontag = button.tag;
    NSLog(@"Market button click at row %d",buttontag);
}
完成按钮的代码:
 -(void)submitMarket
{
    for (UIButton *button in [_tableView subviews]) { // change name of table here
        if ([button isKindOfClass:[UIButton class]]) {
            if (button.tag == buttontag) {
                [button setBackgroundImage:[UIImage imageNamed:@"MarketplaceSelect.png"] forState:UIControlStateNormal];
            } 
        } 
    }
}