zoukankan      html  css  js  c++  java
  • 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

  • 相关阅读:
    rapidjson代码封装类
    CEF3.2623使用记录:windows编译
    ACE主动对象模式
    理解i++和++i
    ubuntu安装vmplayer出现问题的解决方法
    WinSpy涉及的windows api
    winXP下安装opensshd服务
    资源下载链接
    FPM打包工具
    mysql error code
  • 原文地址:https://www.cnblogs.com/beddup/p/5401421.html
Copyright © 2011-2022 走看看