我正在使用可以从here找到的苹果示例模板。只有三个部分时,它可以很好地工作。但是,如果我将节数乘以5,然后从最底部的单元格中打开该节。然后向上滚动,然后向下滚动,您会看到单元格正在被重用,并且当您单击打开的单元格的节标题时,单元格认为它处于关闭状态,从而导致崩溃。
有没有人遇到过同样的问题?有没有人可以解决这个问题?
提前致谢。
最佳答案
示例项目中有一个细微的错误。该示例代码不考虑将APLSectionHeaderView对象重用于其他部分的情况。
添加行
sectionHeaderView.disclosureButton.selected = (section==self.openSectionIndex)?YES:NO;
从方法返回之前
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
并改变这个
APLSectionInfo *previousOpenSection = (self.sectionInfoArray)[previousOpenSectionIndex];
previousOpenSection.open = NO;
[previousOpenSection.headerView toggleOpenWithUserAction:NO];
对此
APLSectionInfo *previousOpenSection = (self.sectionInfoArray)[previousOpenSectionIndex];
previousOpenSection.open = NO;
if (previousOpenSection.headerView.section == previousOpenSectionIndex) {
[previousOpenSection.headerView toggleOpenWithUserAction:NO];
}
在方法中
- (void)sectionHeaderView:(APLSectionHeaderView *)sectionHeaderView sectionOpened:(NSInteger)sectionOpened
关于ios - TVAnimationsGestures可重用的错误:,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/22521591/