我有包含自定义单元格的表格视图。当用户单击该行时,每个单元格都有我想要翻转的视图。我成功地使它适用于这个。但是我遇到的问题是当用户单击其他行时,我想翻转回前一个单元格的原始视图并翻转当前单击的行。
这是一些代码
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
CustomCell *selectedCell =
(CustomCell *)[self.AlbumViewTable cellForRowAtIndexPath:self.current_index];
//if other row is already flipped then make it back to original state.
if(otherRowIsFlipped){
selectedCell.defaultImage = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"defaultIndecator.jpg"]];
selectedCell.defaultImage = CGRectMake(0, 0, 43, 43);
[self flipView:selectedCell.flipViewContainer From:selectedCell.activity To:selectedCell.defaultImage];
}
CustomCell * new_row =
(CustomCell *)[self.AlbumViewTable cellForRowAtIndexPath:indexPath];
new_row.activity = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhite];
new_row.activity.frame = CGRectMake(0, 0, 43, 43);
[new_row.activity startAnimating];
//this method is merely called UIView subroutine to flip between two view
[self flipView:new_row.flipViewContainer From:new_row.defaultImage To:new_row.activity];
[self.AlbumViewTable deselectRowAtIndexPath:indexPath animated:YES];
}
我能够翻转先前选择的行并翻转当前选择的行,但是我发现奇怪的事情是,当我向下滚动表格视图时,翻转视图出现在从未被选择的行上。
我试图在 CustomCell 类中创建属性并尝试翻转但也没有运气。我不确定这种方法是否正确,但它似乎有效,除非我向下滚动以加载其他行。
我很感激任何建议。谢谢