设为首页 加入收藏

TOP

iOS开发 - View Controller 的paging
2017-10-13 10:17:27 】 浏览:9570
Tags: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

 

】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇二维码的生成和扫描 下一篇【Swift学习】Swift编程之旅---集..

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目