我正在使用基于UITableView的手风琴视图构建应用程序。此代码基于Apple示例代码,可以找到here或here。 在示例代码中,我试图修复的问题就在那里,所以我知道这不是我介绍的内容。
如果您打开多个部分而未明确关闭前一部分,则可以同时打开多个部分。这可能导致崩溃,可以通过按下按钮1,2,3,1,1,3来复制。
在我的应用程序中,我尝试关闭上一部分,并在打开新部分时标题中的按钮进入未选择状态,这样您只能打开一个部分并选择一个部分标题按钮一次。如果有人对此示例代码或使用tableview有任何经验,我很乐意纠正这一点,特别是因为这是Apple自己代码中固有的问题
答案 0 :(得分:2)
永远不会设置APLSectionInfo的属性APLSectionHeaderView * headerView。
所以在tableView委托方法中设置sectionInfo.headerView = sectionHeaderView
。
-(UIView*)tableView:(UITableView*)tableView viewForHeaderInSection:(NSInteger)section {
APLSectionHeaderView *sectionHeaderView = [self.tableView dequeueReusableHeaderFooterViewWithIdentifier:SectionHeaderViewIdentifier];
APLSectionInfo *sectionInfo = (self.sectionInfoArray)[section];
sectionHeaderView.titleLabel.text = sectionInfo.play.name;
sectionHeaderView.section = section;
sectionHeaderView.delegate = self;
sectionInfo.headerView = sectionHeaderView;
return sectionHeaderView;
}