• iOS开发 - View Controller 的paging


    在学习开源中国ios 源码时,发现其实现view controllers 的paging的方法如下:

    第一、定义一个容器类的view controller,类似于UIPageViewController. 该vc的主要由两部分组成:

      a 一个title view,用来表明当前内容是什么,并且能够相应用户的点击,切换content

      b 一个table view controller (通过addChildViewController添加,并将table view controller 的view 添加到容器的view中),用来显示内容, 即响应用户的手势实现paging. 

    第二、设置tableview的transform,将tableview旋转90度,设置pagingEnable为yes(UIScrollView的属性),并在table view delegate方法将cell的height设置为屏幕的宽度,这样就能够将table view变成一个能够paging的view了。

    那么如何将view controllers的内容 添加到table view中去呢?首先将所有view controller添加到table view controller中去(addChildViewController),然后将view controller的view 添加到table view cell 的content view中,这样table view cell中的内容就是view controllers 的内容了。

    这种实现主要涉及三个角色:

    1. 容器类的view controller, 主要用来协调title view 和table view controller

    2. table view controller, 用来实现内容水平方向的paging

    3. view controllers,用来提供内容

    因为UIKit本身就提供了paging view controller,不知道为什么不直接用?

    经过测试,可以使用paging view controller实现以上基本功能

    代码:https://github.com/beddup/BeddupPageViewControllerDemo

  • 相关阅读:
    mysql存储过程(查询数据库内表 游标循环 if判断 插入别的表内)
    Java中调用文件中所有bat脚本
    读取pdf内容分页和全部
    前向传播
    Broadcasting 维度扩张的手段
    维度变换
    Selective Indexing
    tensorflow索引和切片
    创建tensor
    c++线程中使用detach()导致的内存非法引用问题
  • 原文地址:https://www.cnblogs.com/beddup/p/5401421.html
Copyright © 2020-2023  润新知