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 ...
随机推荐
- python内置函数、匿名函数、递归
python3--内置函数 内置函数: 截止到python 3.6.2 版本,现在python一共提供了68个内置函数:即python提供给你直接可以拿来使用的所有函数. 内置函数 (点击函数查 ...
- xml布局内容总结(三)--Android
关于xml中经经常使用到边框及边框效果,在此进行一下总结. 3.border(边框及边框效果) (1)直角边框线 <LinearLayout android:layout_wid ...
- iPhone6 和 iPhone 6 plus的适配
苹果每出一款产品,都会引起广大IOS程序猿们的深深关注!是不是又该做适配了?是不是又该学习新东西了?种种的操心挂在心头. 以下我谈谈我对iPhone6 和 iPhone 6 plus适配问题的理解: ...
- iOS开发多线程篇 08 —GCD的常见用法
iOS开发多线程篇—GCD的常见用法 一.延迟执行 1.介绍 iOS常见的延时执行有2种方式 (1)调用NSObject的方法 [self performSelector:@selector(run) ...
- RequireJS 和 Sea.js
相同之处 RequireJS 和 Sea.js 都是模块加载器,倡导模块化开发理念,核心价值是让 JavaScript 的模块化开发变得简单自然. 不同之处 两者的主要区别如下: 定位有差异.Requ ...
- c# 遇到的问题,求解?
c# cannot evaluate expression because the code of the current method is optimized.
- java list map转换成二维数组
/** * *@Title: ListToArray *@Description: list列表转换成二维数组 *@Author: Administrator *@Since: 2018年1月7日下午 ...
- vi全文替换命令
1,$s/str1/str2/g:从第一行到最后一行把str1替换成str2
- 新版期货数据交换(FTD)协议报文分析
因为需要开发模拟CTP后台服务,实现一键切换CTP,所以我们需要分析CTP报文.(基于FTD协议2004版改进) 网上公开的只能找到04年老版本,和现前报文格式出入较大.参考:http://www ...
- java.lang.IllegalArgumentException: n must be positive
public static String randomKey(){ Random random = new Random(); int key = random.nextInt(((int)Syste ...