关于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 ...
随机推荐
- vs 总结
1.可以通过 视图--->属性管理器 来直接配置opencv,一键搞定 2.按住shift键不放,然后移动方向键,可以选中一路数据点. 3.调试程序的利器,调用堆栈,可以定位到程序死的那一刻. ...
- 多线程网页爬虫 python 实现(二)
#!/usr/bin/env python #coding=utf-8 import threading import urllib import re import time cur=0 last= ...
- 【翻译自mos文章】怎么找到OGG Director Server使用的数据库和username?
APPLIES TO: Management Pack for Oracle GoldenGate - Version: 1.0.0.0 - Release: 1.0 Information in t ...
- 【手记】走近科学之为什么JObject不能调用LINQ扩展方法
Json.NET的JObject明明实现了IEnumerable<T>,具体来说是IEnumerable<KeyValuePair<string, JToken>> ...
- 在OpenStack中绕过或停用security group (iptables)
眼下.OpenStack中默认採用了security group的方式.用系统的iptables来过滤进入vm的流量.这个本意是为了安全,可是往往给调试和开发带来一些困扰. 因此,暂时性的禁用它能够排 ...
- CA与数字证书的自结
1.CA CA(Certificate Authority)是数字证书认证中心的简称,是指发放数字证书.管理数字证书.废除数字证书的权威机构. 2.数字证书 如果向CA申请数字证书的单位为A.则他申请 ...
- (WPF)Storyboard
Storyboard是一个为其所包括的动画提供目标信息的容器. 除非动画放在Storyboard中,负责不能在XMAL中被实例化. BeginStoryboard通过将Storyboard加入到触发器 ...
- 4408: [Fjoi 2016]神秘数
4408: [Fjoi 2016]神秘数 Time Limit: 10 Sec Memory Limit: 128 MB Submit: 452 Solved: 273 [Submit][Stat ...
- jvm 调优(1)概念
数据类型 Java虚拟机中,数据类型可以分为两类:基本类型和引用类型.基本类型的变量保存原始值,即:他代表的值就是数值本身:而引用类型的变量保存引用值.“引用值”代表了某个对象的引用,而不是对象本身, ...
- HTML CSS 编码规范
返璞归真,代码规范也是一门艺术 黄金定律 永远遵循同一套编码规范 -- 可以是这里列出的,也可以是你自己总结的.如果你发现本规范中有任何错误,敬请指正.通过open an issue on GitHu ...