类似这种效果:

其实很简单,利用tableview 的plain属性,然后使用section,其实滑上去不动的是  section的headView.

  1. -(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
  2. return ;
  3. }
  4. -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
  5. if (section==||section==) {
  6. return ;
  7. }else{
  8. return ;
  9. }
  10. }
  11.  
  12. -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
  13. UITableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:@"Cell"];
  14. if (cell==nil) {
  15. cell=[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"Cell"];
  16. }
  17. [cell.textLabel setText:[NSString stringWithFormat:@"%ld-%ld",(long)indexPath.section,(long)indexPath.row]];
  18. return cell;
  19. }
  20.  
  21. -(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
  22. if (section==||section==) {
  23. UIView *view=[[UIView alloc]initWithFrame:CGRectMake(, , tableView.frame.size.width, )];
  24. if (section==) {
  25. [view setBackgroundColor:[UIColor redColor]];
  26. }else{
  27. [view setBackgroundColor:[UIColor greenColor]];
  28. }
  29. [view setUserInteractionEnabled:YES];
  30. return view;
  31. }
  32. return nil;
  33. }
  34.  
  35. -(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
  36. if (section==) {
  37. return 0.1;
  38. }else{
  39. return ;
  40. }
  41. }

注:tableview 一定不能设置成group,一定是plain!

tableview 上拉时 标题行出现在顶部不动效果的更多相关文章

  1. 【已解决】iOS11使用MJRefresh上拉加载结束tableView闪动、跳动的问题

    更新提示: [2018年11月20日更新] 经过放置在项目中运行发现,如果在快速滚动tableview的时候会在下面这行代码中崩溃(慢慢的滚动是没关系的-): CGFloat cellHeight = ...

  2. ios基础篇(二十八)—— UITableView的上拉加载

    本文主要展示一个demo实现UITableView的上拉加载数据: 先看看效果图: 接着上拉,加载更多数据: 主要实现的效果是在我们上拉结束拖拽之后,开始加载数据,数据加载的过程中有滚动轮提示用户正在 ...

  3. 仿淘宝商品详情页上拉弹出新ViewController

    新项目就要开始做了,里面有购物那块,就试着先把淘宝商品详情页的效果做了一下. 1.需求 1.第一次上拉时,A视图拉到一定距离将视图B从底部弹出,A视图也向上 2.显示B视图时下拉时,有刷新效果,之后将 ...

  4. ionic上拉加载更多解决方法

    第一步: $scope.hasmore = true;//是否允许上拉加载 $scope.num = 8;//显示条数 第二步://查询显示内容,查出所有的 $scope.Group = functi ...

  5. Android打造(ListView、GridView等)通用的下拉刷新、上拉自动加载的组件

    原文 http://blog.csdn.net/bboyfeiyu/article/details/39253051       前言 下 拉刷新组件在开发中使用率是非常高的,基本上联网的APP都会采 ...

  6. 安卓listView实现下拉刷新上拉加载滑动仿QQ的删除功能

    大家对这些功能都是看的多了,然后对上拉刷新和下拉加载的原理都是非常清楚的,所以实现这功能其实也就是为了让大家能够从众多的同行们来进行比较学习而已,虽然即使是这样,但是面试的时候面试官还是会问你上拉和下 ...

  7. Altera FPGA管脚弱上拉电阻详细设置方法

    Altera FPGA管脚弱上拉电阻的软件设置方法 在使用 Altera 的 FPGA 时候, 由于系统需求, 需要在管脚的内部加上上拉电阻. Quartus II 软件中在 Assignment E ...

  8. mui 上拉加载更多

    看起来很简单的东西,实践过程中还是出现了很多麻烦,比如上拉时,状态条跑到了顶部,因为内容没有添加到容器中,再比如下拉的回调函数使用问题,this的传递. html实现部分: <div class ...

  9. iscroll5实现一个下拉刷新上拉加载的效果

    直接上代码!!! <!DOCTYPE html><html><head lang="en"> <meta charset="UT ...

随机推荐

  1. centos 如何用 rsyslog 搭建本地日志服务(续1: omprog模块与php deamon的配合使用)

    上一篇说到了如何用 rsyslog 搭建本地的日志服务,地址在这里,没有看的童鞋可以先瞅一眼 : http://www.cnblogs.com/smallrookie/p/5677004.html 显 ...

  2. 函数fsp_alloc_seg_inode

    从inode page中申请inode entry inode = fsp_alloc_seg_inode(space_header, mtr); /************************* ...

  3. vijos 1563 疯狂的方格取数

    P1653疯狂的方格取数 Accepted 标签:天才的talent[显示标签]   背景 Due to the talent of talent123,当talent123做完NOIP考了两次的二取 ...

  4. 跟我学LFS LiveUSB制作

    LFS LiveCD启动 插入U盘,查看U盘相应的设备名 $ sudo /sbin/fdisk -l ... Device Boot      Start         End      Block ...

  5. Birt时间参数添加My97日历控件

    首先,思路: 引用My97.js然后为时间参数的textbox添加onclick事件 1.将My97添加到项目中的webcontent目录下(如图:) 2.添加My97引用 在项目路径下找到该文件\w ...

  6. Vim cscope

    /********************************************************************** * Vim cscope * 说明: * 之前使用Vim ...

  7. ClassLoader工作机制

    阅读目录 一.ClassLoader概念 二.JVM平台提供三层classLoader 三.JVM加载class文件到内存有两种方式 四.ClassLoader加载类的过程 五.自定义类加载器 六.实 ...

  8. MS-SQL索引类型

    一.索引的概念     索引就是加快检索表中数据的方法.数据库的索引类似于书籍的索引.在书籍中,索引允许用户不必翻阅完整个书就能迅速地找到所需要的信息.在数据库中,索引也允许数据库程序迅速地找到表中的 ...

  9. js前端验证时间大小

    replace(/\-/g, "\/")是根据验证表达式把日期转化成长日期格式 function checkStartTimeAndEndTime(startTime, endTi ...

  10. 设计模式_Mediator_调停者模式

    形象例子: 四个MM打麻将,相互之间谁应该给谁多少钱算不清楚了,幸亏当时我在旁边,按照各自的筹码数算钱,赚了钱的从我这里拿,赔了钱的也付给我,一切就OK啦,俺得到了四个MM的电话.调停者模式: 调停者 ...