iOS section 随tableview一起滚动
@interface YGSectionHeaderView : UIView
@property NSUInteger section;
@property (nonatomic, weak) UITableView *tableView;
@end
@implementation YGSectionHeaderView
- (void)setFrame:(CGRect)frame{
CGRect sectionRect = [self.tableView rectForSection:self.section];
CGRect newFrame = CGRectMake(CGRectGetMinX(frame),
CGRectGetMinY(sectionRect),
CGRectGetWidth(frame),
CGRectGetHeight(frame));
[super setFrame:newFrame];
}
@end
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
YGSectionHeaderView *sectionHead = [[YGSectionHeaderView alloc] init];
sectionHead.backgroundColor = [UIColor blueColor];
sectionHead.section = section;
sectionHead.tableView = tableView;
return sectionHead;
}
第二种:
- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
if ([scrollView isKindOfClass:[UITableView class]])
{
CGFloat sectionHeaderHeight = ;
if (scrollView.contentOffset.y<=sectionHeaderHeight&&scrollView.contentOffset.y>=) {
scrollView.contentInset = UIEdgeInsetsMake(-scrollView.contentOffset.y, , , );
} else if (scrollView.contentOffset.y>=sectionHeaderHeight) {
scrollView.contentInset = UIEdgeInsetsMake(-sectionHeaderHeight, , , );
}
}
}
iOS section 随tableview一起滚动的更多相关文章
- 设置tableview的滚动范围--iOS开发系列---项目中成长的知识三
设置tableview的滚动范围 有时候tableview的footerview上的内容需要向上拖动界面一定距离才能够看见, 项目中因为我需要在footerviw上添加一个按钮,而这个按钮又因为这个原 ...
- iOS开发:代码通用性以及其规范 第二篇(猜想iOS中实现TableView内部设计思路(附代码),以类似的思想实现一个通用的进度条)
在iOS开发中,经常是要用到UITableView的,我曾经思考过这样一个问题,为什么任何种类的model放到TableView和所需的cell里面,都可以正常显示?而我自己写的很多view却只是能放 ...
- iOS监听tableView组头切换事件
- (void)tableView:(UITableView *)tableView willDisplayHeaderView:(UIView *)view forSection:(NSIntege ...
- IOS详解TableView——内置刷新,EGO,以及搜索显示控制器
内置刷新 内置刷新是苹果IOS6以后才推出的一个API,主要是针对TableViewController增加了一个属性,refreshControl,所以如果想用这个内置下拉刷新的话,最好给你的Tab ...
- iOS UIKit:TableView之编辑模式(3)
一般table view有编辑模式和正常模式,当table view进入编辑模式时,会在row的左边显示编辑和重排控件,如图 42所示的编辑模式时的控件布局:左边的editing control有表 ...
- iOS UIKit:TableView之表格创建(1)
Table View是UITableView类的实例对象,其是使用节(section)来描述信息的一种滚动列表.但与普通的表格不同,tableView只有一行,且只能在垂直方向进行滚动.tableVi ...
- IOS详解TableView——选项抽屉(天猫商品列表)
在之前的有篇文章讲述了利用HeaderView来写类似QQ好友列表的表视图. 这里写的天猫抽屉其实也可以用该方法实现,具体到细节每个人也有所不同.这里采用的是点击cell对cell进行运动处理以展开“ ...
- ios 两个 TableView 之间的联动, TableView 与 CollectionView 之间的联动
两个 TableView 之间的联动, TableView 与 CollectionView 之间的联动 这是一个创建于 359 天前的主题,其中的信息可能已经有所发展或是发生改变. [联动] :两个 ...
- iOS 两个tableview的 瀑布流
iOS 两个tableview的 瀑布流1. [代码]Objective-C //// DocViewController.m// getrightbutton//// Created ...
随机推荐
- Sublime Text 3 JS 格式化插件 JsFormat的配置使用
1.首先需要下载安装包:(下载地址:https://github.com/jdc0589/JsFormat) 2.插件包放到sublime安装目录的Data\Packages目录中 3.快捷键 Ctr ...
- oracle事务块示例
begin Insert into T_SYS_PAGEOPER (FOPERID,FPAGEID) values (152,22); Insert into T_SYS_PAGEOPER (FOPE ...
- memcahced&redis命令行cmd下的操作
一.memcahced 1.安装 执行memcached.exe -d install 把memcached加入到服务中 执行memcached.exe -d uninstall 卸载memcac ...
- [k8s]组件日志级别说明
kubectl 执行命令时候 --v 调试, 也可以用作其他组件的 --v配置 参考: https://kubernetes.io/docs/user-guide/kubectl-cheatsheet ...
- 【ZT】NUMA架构的CPU -- 你真的用好了么?
本文从NUMA的介绍引出常见的NUMA使用中的陷阱,继而讨论对于NUMA系统的优化方法和一些值得关注的方向. 文章欢迎转载,但转载时请保留本段文字,并置于文章的顶部 作者:卢钧轶(cenalulu) ...
- makefile之short函数
函数名称:排序函数-$(sort LIST) 函数功能:给字串"LIST"中的单词以首字母为准进行排序(升序),并去掉重复的单词. 返回值:空格分割的没有重复单词的字串. 函数说明 ...
- oracle 创建表空间及oracle 11g表空间之最大最小
/*分为四步 *//*第1步:创建临时表空间 */create temporary tablespace emaoyi_temp tempfile 'D:\app\Administrator\prod ...
- cp/scp命令详解
cp:拷贝命令 用法: cp [参数] source dest cp [参数] source ... directory 说明:将一个档案拷贝至另一个档案,或数个档案拷贝到另一目录 参数: -a 尽可 ...
- HTTP Range header
http://stackoverflow.com/questions/3303029/http-range-header *************************** 58 down vot ...
- JS中怎样判断undefined