【发布时间】:2013-12-11 09:23:20
【问题描述】:
我有一个 Tableview,我正在使用 customTableview 单元格来显示单元格
在单元格中,当我单击特定按钮时,我有 5 个按钮(评级按钮),按钮的图像必须更改其正常工作,但是当我再次滚动 tableview 时,它们正在更改为正常评级按钮,请参见以下图像为了清楚起见
这是滚动并点击按钮之前的图像
点击评分按钮后,图像会像这样变化
但是当再次滚动单元格时,它会变成第一张图片
请帮帮我
代码:
- (UITableViewCell )tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
dataCell = (DataCel)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (dataCell==nil)
{
NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"DataCel" owner:self options:nil]; dataCell = [nib objectAtIndex:0];
}
return dataCell;
}
【问题讨论】:
-
在 cellForRowAtIndexPath 中显示您的代码
-
您需要记住/存储单元格数据的状态并再次填写!
-
我在 CellForRowAtIndexPath - (UITableViewCell )tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"Cell"; dataCell = (DataCel)[tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (dataCell==nil) { NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"DataCel" owner:self options:nil]; dataCell = [nib objectAtIndex:0]; } 返回数据单元; }
标签: ios iphone objective-c uitableview