我已经做了与tableview中同样的事情,
第一
BOOL sectionIsOpen[2]; // Your Sections number (3 in your case)
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return self.arrMenu.count;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return ((sectionIsOpen[section]) ? [self numberOfRowsInSection:section] : 0);
}
[self numberOfRowsInSection:section
包含条款号
而且当你需要隐藏的方法和
for (NSInteger row = 0; row < [self numberOfRowsInSection:section]; row ++) {
[indxPths addObject: [NSIndexPath indexPathForRow:row inSection:section]
];
}
[self.tblMenu beginUpdates];
if (open) {
[self.tblMenu insertRowsAtIndexPaths:indxPths withRowAnimation:UITableViewRowAnimationFade];
}else{
[self.tblMenu deleteRowsAtIndexPaths:indxPths withRowAnimation:UITableViewRowAnimationFade];
}
sectionIsOpen[section] = open;
[self.tblMenu endUpdates];
希望它可以帮助通段.....
您应该从数据源中删除部分,并通过调用'reloadData'重装集合视图。这将触发'func numberOfSectionsInCollectionView(_ collectionView:UICollectionView) - > Int',你将返回更新的节数。 – fiks
因为我想重用它,那么我只想隐藏/取消隐藏部分,所以在我的情况下删除数据部分不会很好。 – Khuong
如果您确实想要删除@fiks所说的数据源,请尝试将部分大小设置为零? – childrenOurFuture