我以编程方式编写STCollapseTableView。我想要的是当用户进入特定屏幕时,默认情况下必须展开所有标题而不点击任何标题。如果扩展其他标题,我也不希望其他标题崩溃。可能吗?如果没有,那么实现这一目标的其他方法是什么?
我有标题,如果某些标题项包含子项,则它应该已经扩展。
编辑:我已经发现我需要调用以下方法才能展开标题而不点击。
- (void)handleTapGesture:(UITapGestureRecognizer*)tap
{
NSInteger index = tap.view.tag;
if (index >= 0)
{
[self toggleSection:(NSUInteger)index animated:YES];
}
}
如何在显示所有标题后调用此方法?
我使用下面的代码将单元格作为表格的标题视图返回。所以我需要在重新加载tblItems后调用handleTapGesture()方法。
[self.headers removeAllObjects];
for (int i = 0 ; i < [arrItems count] ; i++)
{
[self.headers addObject:[self addViewintoCell:i]];
}
[tblItems reloadData];
[tblItems setContentOffset:CGPointZero animated:NO];
答案 0 :(得分:0)
这是一个懒惰的解决方案,但它不能用作标准解决方案,只需在重新加载包含数据的表后打开加载中的所有部分。
- (void)viewDidLoad
{
[super viewDidLoad];
[self.tableView reloadData];
[self.tableView setExclusiveSections:NO];
//Get Section to open
NSInteger sectionCount = [self.tableView numberOfSections];
for (int needToOpen = 0; needToOpen<sectionCount; needToOpen++) {
//Open Section one by one
[self.tableView openSection:needToOpen animated:NO];
}
}