关于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 ...
随机推荐
- CSP:使用CryptoAPI解码X509证书内容
微软的CryptoAPI提供了一套解码X509证书的函数,一个X509证书解码之后,得到一个PCCERT_CONTEXT类型的结构体指针. 通过该结构体,我们就能够获取想要的证书项和属性等. X509 ...
- 【DataStructure】Description and Introduction of Tree
[Description] At ree is a nonlinear data structure that models a hierarchical organization. The char ...
- appium server参数
转自: http://m.blog.csdn.net/blog/kittyboy0001/40893979 appium Appium是一个开源的,适用于原生或混合移动应用应用( hybrid mob ...
- Html.Partial
老革命永远都在遇上各种似是而非的老问题. 这次,是这个Html.Partial,分部页. Html.Partial与Html.Action有啥区别呢?区别就是,Html.Partial只有一个视图,而 ...
- spark通信原理
https://github.com/apache/spark/tree/master/core/src/main/scala/org/apache/spark/network https://git ...
- strncpy和strlen的可能的实现
#include <stdio.h> #include <stdlib.h>//为避免与标准库中的函数发生混淆,我将它们命名为stringNCopy和stringLength ...
- p1199八数码问题
oj上简化的八数码问题,最强的数据仅仅是20步: 根据曼哈顿距离构造启发函数: 主算法:IDA*:(使用方法好像不太对......) 未用位运算优化: #include<iostream> ...
- LoadRunner性能测试样例分析
LR性能测试结果样例分析 测试结果分析 LoadRunner性能测试结果分析是个复杂的过程,通常可以从结果摘要.并发数.平均事务响应时间.每秒点击数.业务成功率.系统资源.网页细分图.Web服务器资源 ...
- Maze 解题报告
Maze Description You are given a special Maze described as an n*m matrix, please find the shortest ...
- Android 查询 添加 修改 删除通讯录联系人示例
1.AndroidManifest.xml中添加权限 <uses-permission android:name="android.permission.READ_CONTACTS&q ...