tableView组成:
tableView = 一个tableView HeaderView + 若干个section + 一个tableView FooterView ;
section = 一个section HeaderView + 若干个cell + 一个section FooterView ;
tableView组成tableView HeaderView:
##这里是我的代码例子:
tableView HeaderViewtableView FooterView:
##这里是我的代码例子:
tableView FooterViewsection:
设置section的数量:
- (NSInteger)numberOfSectionsInTableView:(UITableView*)tableView;// Default is 1 if not implemented
##这里是我的代码例子:
设置section数量section HeaderView:
设置section headerView的高度:
- (CGFloat)tableView:(UITableView*)tableView heightForHeaderInSection:(NSInteger)section;
设置section headerView样式:
- (nullableUIView*)tableView:(UITableView*)tableView viewForHeaderInSection:(NSInteger)section;// custom view for header. will be adjusted to default or specified header height
##这里是我的代码例子:
section headerViewsection FooterView:
设置section footerView的高度:
- (CGFloat)tableView:(UITableView*)tableView heightForFooterInSection:(NSInteger)section;
设置 section footerView样式:
- (nullableUIView*)tableView:(UITableView*)tableView viewForFooterInSection:(NSInteger)section;// custom view for footer. will be adjusted to default or specified footer height
##这里是我的代码例子:
section footerViewsection cell:
设置cell数量:
- (NSInteger)tableView:(UITableView*)tableView numberOfRowsInSection:(NSInteger)section;
设置cell的高度:
- (CGFloat)tableView:(UITableView*)tableView heightForRowAtIndexPath:(NSIndexPath*)indexPath;
设置cell的样式:
- (UITableViewCell*)tableView:(UITableView*)tableView cellForRowAtIndexPath:(NSIndexPath*)indexPath;
##这里是我的代码例子:
section cell索引:
- (nullableNSArray *)sectionIndexTitlesForTableView:(UITableView*)tableView__TVOS_PROHIBITED;// return list of section titles to display in section index view (e.g. "ABCD...Z#")
##这里是我的代码例子:
tableView索引 点击右面索引进行快速定位UITableViewStyle:
- (instancetype)initWithFrame:(CGRect)frame style:(UITableViewStyle)style NS_DESIGNATED_INITIALIZER;
其中UITableViewStyle分为以下两种:
UITableViewStyleUITableViewStylePlain:
滑动tableView时, section(i)的headerView会保持位置在顶部, 直到下一个section(i+1)的headerView顶替section(i)的headerView; sectionView的FooterView同理.
UITableViewStylePlainUITableViewStyleGrouped:
section的headerView, footerView保持跟tableView一起滑动.
UITableViewStyleGrouped