我已将三个按钮放在UITableViewCell上,并将其背景设置为取消选择单选按钮图像。值滚动时从UITableViewCell清除
单击按钮时,我再次将背景图像设置为选择按钮。
在一排一个选择按钮应该坚持,但滚动时的UITableView所有选择的按钮图像是否清零
有人可以给我的任何想法如何做到这一点以这种方式或其他方式?
我已将三个按钮放在UITableViewCell上,并将其背景设置为取消选择单选按钮图像。值滚动时从UITableViewCell清除
单击按钮时,我再次将背景图像设置为选择按钮。
在一排一个选择按钮应该坚持,但滚动时的UITableView所有选择的按钮图像是否清零
有人可以给我的任何想法如何做到这一点以这种方式或其他方式?
您可能没有正确重用单元格。滚动时,前一个单元格将被UITableView
重新使用,但不会正确更改其内容。这里是你参考的示例代码
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *cellIdentifier = @"CellIdentifier";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
if (cell == nil)
{
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:cellIdentifier] autorelease];
}
cell.textLabel.text = [urDataArray objectAtIndex:indexPath.row];
return cell;
}
在表格数据源中保存你的状态按钮。 将该值设置为您的按钮。表正在滚动时重新加载每个显示的行。
虽然不是一字一句,但它看起来像你从亚当的原始这里解除了这个答案:http://stackoverflow.com/questions/2027455/repeat-problem-of-tableview-cell-during-scrolling-in -iphone/2027478#2027478。如果是这样,你应该给他适当的信贷。 –