关于Page翻页效果, PageViewConrtoller
Page View Controllers
你使用一个page view controller用page by
page的方式来展示内容。一个page view controller管理一个self-contained视图架构。这个架构的父视图由page
View controller管理,并且子视图由你提供的view Controllers管理。
一,解析Page View Controller
一个page view controller有一个单独的视图,是你的内容的存放的地方。
下图显示了page view interface的结构:最外面的棕色视图是父视图控制器,不是page view controller自身。page view controller没有自己的UI;然而,它对它的children做一个翻页效果。

二,page view controller interface的对象:
一个可选的代理,一个可选的数据源,一组current view controllers,一组手势识别者

数据源按需提供viewControllers。
委托提供响应基于手势的导航和方向更改。
view Controllers的数组包含当前要显示的content view controller。数组中的items的数量基于传递给page view controller的选项。
手势识别者只有在数据源被指定时才存在。这些手势识别者使用户通过轻击、flicking(快速滑动)或拖动翻页。
三,创建page view controller interface:
page view controller的view可以被缩放和嵌入到一个视图层次架构中。这意味着,不像一个导航控制器或tab bar controller,page view controller可以在广阔的范围内使用,而不是一些特别的情况。
1,通过stroyboard创建page view controller: Page-Based Application Xcode模版创建一个新的带page view controller的工程。
要添加一个page view controller到一个已经存在的storyboard:
1)拖动一个page view controller,并添加一个page view controller scene 到你的storyboard.
2)在属性检查器中,设置适当的选项。
3)可选地,设置一个委托,数据源
4)。。。
2,通过代码创建一个page view controller:
1)通过initWithTransitionStyle:navigationOrientation:options:方法创建一个page view controller
2)可选地,设置一个代理、数据源
3)设置初始的content view controllers
4) 在屏幕上显示page view controller的view。
3,设置最初的view controller:无论你是通过代码创建还是通过IB创建了一个page view controller,你都需要在将其显示到屏幕之前指定一个初始的view controller。
调用setViewControllers:direction:animated:completion:方法。
如果page view controller没有initial view controller,它的shouldAutorotateToInterfaceOrientation:返回NO,并抛出一个异常。
四,自定义初始化行为:
在初始化时,你传递给initWithTransitionStyle:navigationOrientation:options:方法的参数值和选项来自定义一个page view controller。在初始化后,这些属性都是只读的。你可以自定义:
1)The direction in which navigation occurs.
2)The location of the spine.(书脊的位置)
3)The transition style. In iOS 5, the only valid transition style is UIPageViewControllerTransitionStylePageCurl.
例如,
Listing 3-1 Customizing a page view controller
NSDictionary
* options = [NSDictionary dictionaryWithObject:[NSNumber
numberWithInt:UIPageViewControllerSpineLocationMid]
forKey:UIPageViewControllerOptionSpineLocationKey];
UIPageViewController
*pageViewController = [[UIPageViewController
alloc]initWithTransitionStyle:UIPageViewControllerTransitionStylePageCurl
navigationOrientation:UIPageViewControllerNavigationOrientationHorizontal
options:options];
五、在运行时使用代理自定义行为:
UIPageViewControllerDelegate协议:可以在设备方向更改时和用户导航到一个新页时执行动作,并且它可以更新书脊的位置来响应方向的转变。
六、通过数据源提供内容:
数
据源的方法被当前显示的view controller调用,并返回它之前和之后的view
controller。为了简化查找前面和后面的viewcontroller,你可以在你的view
controller里存储额外的信息,例如一个page number。
如果指定了数据源,page view controller将关联手势识别到它的view。这些手势通过gestureRecognizers属性访问。
要移动手势识别到另一个view,传递gestureRecognizers属性的值给目标view的addGestureRecognizer:方法。
例如,如果你的page view controller没有充满屏幕,你将手势识别传递给其superview,可以更好地翻页,而不用必须在page view controller内翻页。
七,通过设置current view controller提供内容:
setViewControllers:direction:animated:completion:方法直接控制显示哪些内容。
如果你没有设置数据源,你需要提供UI来移动pages,例如前进和后退按钮。手势驱动的导航只有在在你提供了数据源的时候才可用。
八,特别考虑Right-to-Left和Bottom-to-Top Content:
要通过数据源,使用一个page view controller来显示一个right-to-left或bottom-to-top内容,只需要反转下面两个方法的实现:
1)在你的数据源中,实现pageViewController:viewControllerBeforeViewController: 并返回之后的的viewController
2)pageViewController:viewControllerAfterViewController:返回前面的viewController>
并且,你一般要设置书脊的位置为UIPageViewControllerSpineLocationMax
原文网址: http://supershll.blog.163.com/blog/static/370704362012725326323/
关于Page翻页效果, PageViewConrtoller的更多相关文章
- webapp应用--模拟电子书翻页效果
前言: 现在移动互联网发展火热,手机上网的用户越来越多,甚至大有超过pc访问的趋势.所以,用web程序做出仿原生效果的移动应用,也变得越来越流行了.这种程序也就是我们常说的单页应用程序,它也有一个英文 ...
- turn.js 图书翻页效果
今天用turn.js 做图书的翻页效果遇到问题: 图片路径总是出错 调了一天,总算调出来了 我用的thinkphp,其他的不知道是不是一样 三 个地方要改动: 1.后台查出地址 注意的地方:1.地址要 ...
- 纯css3写的仿真图书翻页效果
对css3研究越深入,越觉得惊艳.css3说不上是万能的,但是它能实现的效果也超出了我的想象.它的高效率和动画效果的流畅性很多情况下能替代js的作用.个人习惯css3能实现的效果就不会用js,虽然在国 ...
- ViewPager实现滑动翻页效果
实现ViewPager的滑动翻页效果可以使用ViewPager的setPageTransformer方法,如下: import android.content.Context; import andr ...
- HTML5开发的翻页效果实例
简介2010年F-i.com和Google Chrome团队合力致力于主题为<20 Things I Learned about Browsers and the Web>(www.20t ...
- turn.js中文API 写一个翻页效果的参数详细解释
$('.flipbook').turn({ width: 922, height: 600, elevation: 50, gradients: true, a ...
- javascript移动端 电子书 翻页效果
1.后端给一长串的纯文本 2.前端根据屏幕的高度,将文本切割为 n 页 3.使用插件 turn.js 将切割好的每页,加上翻书效果 <!DOCTYPE html> <html lan ...
- 采用cocos2d-x lua 的listview 实现pageview的翻页效果之上下翻页效果
--翻页滚动效果local function fnScrollViewScrolling( sender,eventType) -- body if eventType == 10 the ...
- css实现翻页效果
如图,鼠标移动到图上,实现右上角翻页的效果,本例主要border边框的设置. 一.基本概念 <html> <head> <style> #demo{ width:0 ...
随机推荐
- centos下的hadoop服务器的配置
是我安装CentOS服务器的过程,记录下来,与大家一起分享. 安装操作系统 CentOS 6.2 ,CentOS-6.2-i386-bin-DVD1.iso(32位) ,CentOS-6.2-x86_ ...
- C++ primer 模板与泛型编程
继续浏览c++ primer 看到模板与泛型编程这章.就顺便把这几节的代码综合了下,对一个Queue队列模板的实现 贴一下代码(看完书.自己敲,忘记了哪再看下书) #include <ostre ...
- Screen 状态栏配置
http://havee.me/linux/2010-08/screen-status-bar.html Screen 状态栏配置 GNU 的 screen 是一个很好的工具.如果需要经常或者大量的登 ...
- 减肥 day1
今天是我减肥第一天,现在体重是147斤, 早晨吃了一碗面,喝了一碗奶,中午吃了一个apple. 6点钟去打篮球,晚上去食堂稍微吃一点东西.
- 一个UserState(WCF)的小例子
练习WCF的时候,遇到了一个异步调用(也许是)的问题.后来使用了重载参数UserState试着解决了一下,但不是很清楚这个参数的其他用途.现在贴出这个例子. Service部分: 客户端后台调用部分: ...
- storage engine option for directoryPerDB
Requested option conflicts with current storage engine option for directoryPerDB; you requested true ...
- IMP-00009 And IMP-00028
导出文件异常结束” 错误,google一下,发现可能有如下原因导致 1.imp的数据太大,没有写buffer和commit 2.两个数据库字符集不同 3.从低版本exp的dmp文件,向高版本imp 4 ...
- iOS webView的常见属性和方法
一.初始化与三种加载方式 UIWebView继承与UIView,因此,其初始化方法和一般的view一样,通过alloc和init进行初始化,其加载数据的方式有三种: 第一种: - (void)load ...
- Mysql常见函数
一.单行函数 1.字符函数 concat拼接 substr截取子串 upper转换成大写 lower转换成小写 trim去前后指定的空格和字符 ltrim去左边空格 rtrim去右边空格 replac ...
- codeforces 679e Bear and Bad Powers of 42
传送门:http://codeforces.com/contest/679/problem/E 题目意思很清晰,给你一个序列,要求你完成以下三个操作: 1.输出A[i] 2.将[a,b]区间的所有数字 ...