首页 > 移动平台 > 详细

iOS开发 - View Controller 的paging

时间:2016-04-17 17:48:08      阅读:254      评论:0      收藏:0      [点我收藏+]

在学习开源中国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中去,然后将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

 

iOS开发 - View Controller 的paging

原文:http://www.cnblogs.com/beddup/p/5401421.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!