All Projects → Nododo → AdoHideTableSection

Nododo / AdoHideTableSection

Licence: other
An easy way to hide or show section in a tableview

Programming Languages

objective c
16641 projects - #2 most used programming language

Projects that are alternatives of or similar to AdoHideTableSection

Flowkit
A declarative type-safe framework for building fast and flexible list with Tables & Collection
Stars: ✭ 215 (+277.19%)
Mutual labels:  uitableview
DraggableModalTransition
Enables dragging interaction and animation of scrollView in a similar way to Facebook Messenger app.
Stars: ✭ 63 (+10.53%)
Mutual labels:  uitableview
PagedLists
Paginated UITableView and UICollectionViews for iOS.
Stars: ✭ 69 (+21.05%)
Mutual labels:  uitableview
Automatic Height Tagcells
This is a sample project to implement features with dynamic height of UITableViewCell based on autolayout, tags aligned automatically and clickable tags.
Stars: ✭ 229 (+301.75%)
Mutual labels:  uitableview
react-native-js-tableview
A JavaScript implementation for TableView that looks great on both iOS and Android.
Stars: ✭ 23 (-59.65%)
Mutual labels:  uitableview
AUPickerCell
Embedded picker view for table cells.
Stars: ✭ 19 (-66.67%)
Mutual labels:  uitableview
Expandable Table View
Expandable UITableView in iOS
Stars: ✭ 180 (+215.79%)
Mutual labels:  uitableview
VPAutoComplete
A simple Auto Complete UITextField also support UITableView written in swift 4.2
Stars: ✭ 20 (-64.91%)
Mutual labels:  uitableview
IQListKit
Model driven UITableView/UICollectionView
Stars: ✭ 51 (-10.53%)
Mutual labels:  uitableview
RevivalxUITableView
This source code provides example for UITableView using Alamofire and Haneke.
Stars: ✭ 13 (-77.19%)
Mutual labels:  uitableview
Magearrefreshcontrol
An iOS refresh control with gear animation
Stars: ✭ 231 (+305.26%)
Mutual labels:  uitableview
Squaremosaiclayout
An extandable mosaic UICollectionViewLayout with a focus on extremely flexible customizations 🔶
Stars: ✭ 243 (+326.32%)
Mutual labels:  uitableview
TreeView
"TreeView - sub-cells simplified" (c). Enable subcells in UITableView with a single drop-in extension. CocoaPod:
Stars: ✭ 54 (-5.26%)
Mutual labels:  uitableview
Expandabletable
AZExpandable is a lightweight proxy for UITableView to expand cells.
Stars: ✭ 218 (+282.46%)
Mutual labels:  uitableview
DropDownTableView
Here is a drop-down TableView.
Stars: ✭ 16 (-71.93%)
Mutual labels:  uitableview
Swiftycomments
UITableView based component designed to display a hierarchy of expandable/foldable comments.
Stars: ✭ 200 (+250.88%)
Mutual labels:  uitableview
Cyanic
Declarative, state-driven UI framework
Stars: ✭ 32 (-43.86%)
Mutual labels:  uitableview
StackableTableView
A UITableView subclass that enables setting an array of views for both headers and footers utilizing UIStackView
Stars: ✭ 72 (+26.32%)
Mutual labels:  uitableview
Mentions
An easy way to add mentions and hashtags
Stars: ✭ 24 (-57.89%)
Mutual labels:  uitableview
HDEmptyView
一个Swift语言封装的EmptyView显示库,可作用于WKWebView、UITableView、UICollectionView 无网络提醒或者空数据提醒
Stars: ✭ 29 (-49.12%)
Mutual labels:  uitableview

AdoHideTableSection

An easy way to hide or show section in a tableview

NOTE:

Version 0.2 添加block用来处理隐藏section之后的事件

请记得把自定义cell的clipToBounds设置为YES,这样才不会让cell的内容“露”出来。。。

传统的删除UITableView的section,往往是通过删除数据源,然后reloadSections的方法完成。但是如果想隐藏、显示多个section的时候,重复的addObject和removeObject并附带各种逻辑判断,是不是整个人都不开心了。

就像完成下面的功能:(gif中的内容涉及公司车型数据库,就不拿出来献丑了。demo中的颜色搭配,请大家忍耐下吧~)

考虑了一下,想要简单的实现这个功能,最有效的方法就是为UITableView添加一个category,从而不干扰项目中的其他部分。

那么,这里之所以用hide而不是delete,就是把需要隐藏的section中的cell高度设置为0,需要显示时再还原为初始高度。那么设置一个defaultHeight是必须的咯。在category添加这么一个属性,咋办?对,用一下runtime。

@property (nonatomic,assign)CGFloat ado_defaultCellHeigt;

有了默认高度,那么需要一个集合保留那些section是被隐藏的,那些section是正常的,那么哪种集合类型比较好呢?参考:

- (void)reloadSections:(NSIndexSet *)sections withRowAnimation:(UITableViewRowAnimation)animation NS_AVAILABLE_IOS(3_0);

API用了NSIndexSet类型,仔细研究下,发现NSIndexSet用来实现我们的功能最好不过了。而我们需要不断的增加或减少section,所有选择其子类:NSMutableIndexSet,能addIndex,removeIndex,并能判断index是否存在:containsIndex,是不是觉得很完美?

- (NSMutableIndexSet *)ado_hideSections;

这里存储了隐藏和显示的section,那么每个section中cell中的高度自然要我们自己计算了。根据self.ado_hideSections存储的section,返回不同的高度.

- (CGFloat)ado_configSectionHeightInSection:(NSInteger)section;

关于AdoTableViewHeaderFooterView.h的写法,是我不想在controller中过多的增加代码,想出来的“歪招”。给其增加了一个属性:headerSection,让其记住自己属于UITableView中的那个section,更简单的完成自己的使用。

给AdoTableViewHeaderFooterView的contentView增加一个UIControl,响应隐藏或显示的事件。

UITableView *superView = (UITableView *)self.superview; [superView ado_hideSection:self.headerSection];

获取父视图,隐藏或显示自己的section,搞定~

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].