iOS开发-设置headerInsectionView不悬浮
2017-04-11 10:13
1526 查看
UITableView有两个headerView:tableHeaderView、和headerInsectionView(组头视图)。
给tableView添加这两个View:tableHeaderView是通过tableView.tableHeaderView = XXXView 的方式添加的,而headerInsectionView是通过-
(UIView *)tableView:(UITableView *)tableView
viewForHeaderInSection:(NSInteger)section代理方法添加的。
UITableView的Style为Plain时,当tableView上移顶端的tableHeaderView会跟着滑出窗口,而headerInsectionView则会悬浮固定在窗口顶端不随着滑动继续上移。
UITableView的Style为Grouped时,当tableView上移顶端的tableHeaderView会跟着滑出窗口,而headerInsectionView则会随着滑动继续上移。
UITableView的Style为Plain时禁止headerInsectionView固定在顶端:
- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
CGFloat sectionHeaderHeight =
50;
if(scrollView.contentOffset.y<=sectionHeaderHeight&&scrollView.contentOffset.y>=0)
{
scrollView.contentInset =
UIEdgeInsetsMake(-scrollView.contentOffset.y,
0, 0,0);
} else
if (scrollView.contentOffset.y>=sectionHeaderHeight) {
scrollView.contentInset =
UIEdgeInsetsMake(-sectionHeaderHeight,
0, 0,
0);
}
}
给tableView添加这两个View:tableHeaderView是通过tableView.tableHeaderView = XXXView 的方式添加的,而headerInsectionView是通过-
(UIView *)tableView:(UITableView *)tableView
viewForHeaderInSection:(NSInteger)section代理方法添加的。
UITableView的Style为Plain时,当tableView上移顶端的tableHeaderView会跟着滑出窗口,而headerInsectionView则会悬浮固定在窗口顶端不随着滑动继续上移。
UITableView的Style为Grouped时,当tableView上移顶端的tableHeaderView会跟着滑出窗口,而headerInsectionView则会随着滑动继续上移。
UITableView的Style为Plain时禁止headerInsectionView固定在顶端:
- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
CGFloat sectionHeaderHeight =
50;
if(scrollView.contentOffset.y<=sectionHeaderHeight&&scrollView.contentOffset.y>=0)
{
scrollView.contentInset =
UIEdgeInsetsMake(-scrollView.contentOffset.y,
0, 0,0);
} else
if (scrollView.contentOffset.y>=sectionHeaderHeight) {
scrollView.contentInset =
UIEdgeInsetsMake(-sectionHeaderHeight,
0, 0,
0);
}
}
相关文章推荐
- iOS开发-设置headerInsectionView不悬浮
- iOS开发 TableView的headerInSectionView 不悬浮
- 【iOS开发】关于Xcode8后产生的viewForHeaderInSection、viewForFooterInSection设置不产生效果的问题
- ios开发之--ios11适配:TableView的heightForHeaderInSection设置高度无效/UISearchBar消失
- iOS开发:Xcode 7之后viewForHeaderInSection、viewForFooterInSection设置内容不产生效果的解决方法
- 设置headerInsectionView不悬浮
- iOS开发——heightForHeaderInSection设置高度无效
- UITableView设置headerInsectionView不悬浮
- ios:改变tableview的titleForHeaderInSection字体颜色设置
- iOS开发UI— QQ好友列表(处理头部控件的点击)viewForHeaderInSection:
- iOS开发笔记--去掉tableview中section的headerview粘性
- iOS开发笔记--去掉tableview中section的headerview粘性
- iOS UITableView:section的Header以及Footer不悬浮停留在屏幕的方法(非在scrollView代理实现的方法)
- iOS开发笔记--去掉tableview中section的headerview粘性
- iOS中tableView每一个section的header的悬浮位置的解决
- iOS开发笔记--去掉tableview中section的headerview粘性
- 【iOS】tableView:viewForHeaderInSection: 方法未调用
- iOS开发笔记--去掉tableview中section的headerview粘性
- iOS tableview viewForHeaderInSection 自定义
- iOS开发-进阶:设置group类型tableview的section间距