我想将所有UIButton viewwithTag :4000
(下面的代码)添加UITableView
到数组中。我怎样才能做到这一点?请给我任何建议。这是我的代码创建 uitableview :
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
NSString *identifier = @"identifier";
cell = [_tableView dequeueReusableCellWithIdentifier:identifier];
UIButton *market = [UIButton buttonWithType:UIButtonTypeCustom];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:identifier] autorelease];
[market setFrame:CGRectMake(200, 6, 30, 30)];
market.tag = 4000;
[cell.contentView addSubview:market];
}
UIButton *marketButton = (UIButton*)[cell.contentView viewWithTag:4000];
[marketButton setTag:indexPath.row];
if([sellingArray count]>0)
{
NSLog(@"sellingArray %@",sellingArray);
if([[sellingArray objectAtIndex:indexPath.row] isEqualToString:@"0"]) // nothing
{
[marketButton setImage:[UIImage imageNamed:@"Marketplace.png"] forState:UIControlStateNormal];
}
else if([[sellingArray objectAtIndex:indexPath.row] isEqualToString:@"2"]) // marketplace
{
[marketButton setImage:[UIImage imageNamed:@"MarketplaceSelect.png"] forState:UIControlStateNormal];
}
}
[marketButton setTag:indexPath.row];
}
}
return cell;
}
我想在 reloadData 时更改 Marketbutton 的图像,但它不能更改,所以我想将所有 Marketbutton 添加到数组中,然后为每个按钮设置图像。请帮助我。谢谢