【发布时间】:2011-04-29 08:05:39
【问题描述】:
我有这段代码,其中“lineaRedToday”是一个 UIImageView:
- (void)viewDidLoad {
[super viewDidLoad];
lineaRedToday = [UIImage imageNamed:@"line4.png"];}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *MyIdentifier = @"MyIdentifier";
MyIdentifier = @"tblCellView";
TableViewCell *cell = (TableViewCell*)[tableView dequeueReusableCellWithIdentifier:MyIdentifier];
if(cell == nil) {
[[NSBundle mainBundle] loadNibNamed:@"TableViewCell" owner:self options:nil];
cell = tblCell;
}
cell.selectionStyle = UITableViewCellSelectionStyleNone;
[[lineDay objectAtIndex:currentTodaylineRed -1] setImage:lineaRedToday];
return cell;
- (IBAction) change{
lineaRedToday = [UIImage imageNamed:@"linea.png"];
[lineDay setImage:lineaRedToday];
[myTableView reloadData];
}
这是一个带有 15 个自定义 UITableViewCell 的 UITableView,我想在 UIImageView 上更改图像,这个 ImageView 是“lineDay”,lineDay 存在于所有单元格中,我想在所有单元格中更改其图像,但是 IBAction “更改”仅在最后一个单元格中更改 UIImageView 而根本不更改......为什么?
【问题讨论】:
标签: objective-c cocoa-touch ios uitableview tableview