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 ...
随机推荐
- json servlet通信 显示数据
servlet //输出JSON格式的省份信息 @WebServlet("/ServletDemo1") public class ServletDemo1 extends Htt ...
- 采集Snoopy.class.php
<?php /************************************************* Snoopy - the PHP net client Author: Mont ...
- python oop面向对象笔记
#coding:utf-8 class Person(object): def __init__(self,name,wage): self.name = name self.wage = wage ...
- 0xffff0000颜色表示
0xffff0000表红色,意思是: A:ff=255 R:ff=255 G:00=0 B:00=0 可如下将(255,0,0,255)转成0xffff0000并输出: inline DWORD RG ...
- Redis 5种数据类型,2种特殊数据处理策略
5种数据类型 String [html] view plaincopy 1.String 经常使用命令: 除了get.set.incr.decr mget等操作外,Redis还提供了下面一些操 ...
- CentOS下yum常用命令
1.自动搜索最快镜像插件:yum install yum-fastestmirror 2.更换163的源. 首先:备份/etc/yum.repos.d/CentOS-Base.repomv /etc/ ...
- Atitit. 脚本语言的断点单步调试的设计与实现 attialx 总结 php 参照java
Atitit. 脚本语言的断点单步调试的设计与实现 attialx 总结 php 参照java 1. 断点的实现:手动断点 die和exit是等价的 1 2. 变量表的实现 1 3. print_r( ...
- python学习之join()
str.join(iterable) 该方法用来分隔字符串的. 例子 >>> b':'.join((b'leo',b'999')) b'leo:999' >>> ' ...
- linux根据进程号PID查找启动程序的全路径
linux根据进程号PID查找启动程序的全路径 2014-01-25 11:09 18629人阅读 评论(0) 收藏 举报 分类: Linux系统管理(29) 版权声明:本文为博主原创文章,未经博 ...
- OSI七层模型与TCP/IP五层模型详解
博主是搞是个FPGA的,一直没有真正的研究过以太网相关的技术,现在终于能静下心学习一下,希望自己能更深入的掌握这项最基本的通信接口技术.下面就开始搞了. 一.OSI参考模型 今天我 ...