iOS:翻页效果
//
// main.m
// Hello
//
// Created by lishujun on 14-8-28.
// Copyright (c) 2014年 lishujun. All rights reserved.
// // 翻页太快会有问题,未解决
//Unbalanced calls to begin/end appearance transitions for <ContentViewControler: 0x8f3d570>. #import <UIKit/UIKit.h> // -----------------------------内容视图控制器-----------------------------
@interface ContentViewControler : UIViewController
@property (nonatomic,strong) UILabel *label;
@property NSString *message;
@end @implementation ContentViewControler
@synthesize label ;
@synthesize message = _message; -(id)initWithMessage:(NSString *)aMessage
{
_message = aMessage;
return self;
} -(void) viewDidLoad
{
//[super viewDidLoad]; //创建label对象
label = [[UILabel alloc]initWithFrame:CGRectMake(0.0, 0.0, 320.0, 30.0)];
label.text = _message;
label.center = self.view.center;
label.textAlignment = UITextAlignmentCenter;
label.backgroundColor = [UIColor clearColor];
label.textColor = [UIColor redColor]; //在视图上添加label
[self.view addSubview:label];
self.view.backgroundColor = [UIColor lightGrayColor];
} -(void) updateMessage:(NSString*)aMessage
{
_message = aMessage;
label.text = _message;
}
@end // -----------------------------视图控制器对象-----------------------------
@interface MyPageViewController : UIViewController <UIPageViewControllerDataSource>
{
int pageIndex;
}
@property (strong, nonatomic) UIPageViewController *pageViewControler;
@property (strong, nonatomic) NSArray *array;
@end @implementation MyPageViewController @synthesize pageViewControler = _pageViewControler;
@synthesize array = _array; -(void) viewDidLoad
{
[super viewDidLoad]; self.view.frame = CGRectMake(0.0f, 0.0f, 320.0f, 440.0f); ContentViewControler *content1 = [[ContentViewControler alloc]initWithMessage:@"Hello"];
ContentViewControler *content2 = [[ContentViewControler alloc]initWithMessage:@""];
NSArray *array = @[content1];
NSLog(@"%@",content1);
_array = [[NSArray alloc]initWithObjects:content1, content2, nil]; _pageViewControler = [[UIPageViewController alloc]
initWithTransitionStyle: UIPageViewControllerTransitionStylePageCurl
navigationOrientation: UIPageViewControllerNavigationOrientationHorizontal
options: nil]; [_pageViewControler setViewControllers:array
direction:UIPageViewControllerNavigationDirectionForward
animated:YES
completion:NULL]; _pageViewControler.dataSource = self; [self addChildViewController:_pageViewControler];
[self.view addSubview:_pageViewControler.view]; pageIndex = ;
} //--------------- data source 方法 ----------------- - (UIViewController *)
pageViewController:(UIPageViewController *)pageViewController
viewControllerBeforeViewController:(UIViewController *)viewController
{
ContentViewControler *aViewController = (ContentViewControler*)[self changeViewControler:viewController];
[aViewController updateMessage:@"i'm lishujun too"];
return aViewController;
} - (UIViewController *)
pageViewController:(UIPageViewController *)pageViewController
viewControllerAfterViewController:(UIViewController *)viewController
{
ContentViewControler *aViewController = (ContentViewControler*)[self changeViewControler:viewController];
[aViewController updateMessage:@"i'm lishujun"];
return aViewController;
} // --- 自定义方法,在只有两个元素的数组里切换元素---
-(UIViewController *) changeViewControler:(UIViewController*)viewController
{
int index = [_array indexOfObject:viewController];
switch(index)
{
case :
return _array[];
case :
return _array[];
}
return nil;
}
@end // -----------------------------委托对象-------------------------------
@interface HelloWorldAppDelegate : NSObject <UIApplicationDelegate>
{
IBOutlet UIWindow *window;
} @property (nonatomic, retain) UIWindow *window;
@property (nonatomic, retain) MyPageViewController *viewController;
@property (nonatomic, retain) UINavigationController *nav;
@end @implementation HelloWorldAppDelegate @synthesize window;
@synthesize viewController; -(void) applicationDidFinishLaunching:(UIApplication *)application
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen]bounds]];
self.viewController = [[MyPageViewController alloc]init];
//self.window.rootViewController = self.viewController; self.nav = [[UINavigationController alloc]initWithRootViewController: viewController];
[self.nav setNavigationBarHidden:YES]; //隐藏导航栏,位于视图顶部
[self.nav setToolbarHidden:YES]; //隐藏工具栏,位于视图底部 self.window.rootViewController = self.nav; [self.window makeKeyAndVisible];
} @end // -----------------------------程序入口-----------------------------
int main(int argc, char * argv[])
{
@autoreleasepool {
return UIApplicationMain(argc, argv, nil, @"HelloWorldAppDelegate");
}
}
iOS:翻页效果的更多相关文章
- iOS:横向使用iPhone默认的翻页效果
大致思路使用两层辅助UIView的旋转来实现添加后的View的横向翻页效果 CATransform3D transformA = CATransform3DRotate(CATransform3DId ...
- 关于Page翻页效果, PageViewConrtoller
Page View Controllers你使用一个page view controller用page by page的方式来展示内容.一个page view controller管理一个self-c ...
- webapp应用--模拟电子书翻页效果
前言: 现在移动互联网发展火热,手机上网的用户越来越多,甚至大有超过pc访问的趋势.所以,用web程序做出仿原生效果的移动应用,也变得越来越流行了.这种程序也就是我们常说的单页应用程序,它也有一个英文 ...
- 采用cocos2d-x lua 的listview 实现pageview的翻页效果之上下翻页效果
--翻页滚动效果local function fnScrollViewScrolling( sender,eventType) -- body if eventType == 10 the ...
- css实现翻页效果
如图,鼠标移动到图上,实现右上角翻页的效果,本例主要border边框的设置. 一.基本概念 <html> <head> <style> #demo{ width:0 ...
- turn.js 图书翻页效果
今天用turn.js 做图书的翻页效果遇到问题: 图片路径总是出错 调了一天,总算调出来了 我用的thinkphp,其他的不知道是不是一样 三 个地方要改动: 1.后台查出地址 注意的地方:1.地址要 ...
- (旧)子数涵数·PS ——翻页效果
一.首先在网络上下载一张图片,作为素材.这是我下载的素材,至于为什么选择这张照片呢,当然不是因为自己的一些羞羞的念头啦. 二.打开Photoshop,我使用的版本是CS3(因为CS3所占的磁盘空间较小 ...
- ajax翻页效果模仿yii框架
ajax翻页效果,模仿yii框架. 复制代码代码如下: <!DOCTYPE html> <html> <head> <title>ajax分页_w ...
- 纯css3写的仿真图书翻页效果
对css3研究越深入,越觉得惊艳.css3说不上是万能的,但是它能实现的效果也超出了我的想象.它的高效率和动画效果的流畅性很多情况下能替代js的作用.个人习惯css3能实现的效果就不会用js,虽然在国 ...
随机推荐
- [D3] 12. Basic Transitions with D3
<!DOCTYPE html> <html> <head lang="en"> <meta charset="UTF-8&quo ...
- iOS UIKit:CollectionView之布局(2)
Collection view使用UICollectionViewFlowLayout对象来管理section中的cell,该对象是一种流布局方式,即在collection view中的section ...
- 第二篇:web之前端之css
前端之css 前端之css 本节内容 css概述及引入 css选择器 css常用属性 1.css概述及引入 CSS概述 CSS是Cascading Style Sheets的简称,中文称为层叠样式 ...
- 【锋利的jQuery】学习笔记01
第一章 认识jQuery 一.常见的JS库 Prototype 最早的js库之一.把好用JS方法组合,缺点结构松散. Dojo 离线存储API.生成图标组件.矢量图形库.Comet支持.企业级JS库, ...
- C#中堆和栈的区别分析(有待更新总结2)
转载:http://blog.csdn.net/Zevin/article/details/5731965 线程堆栈:简称栈 Stack 托管堆: 简称堆 Heap 使用.Net框架开发程序的时候,我 ...
- 一封给“X教授”的回信(讨论Socket通信)
转载:http://www.cnblogs.com/tianzhiliang/archive/2011/03/02/1969187.html 前几天"X教授"发Email与我讨论S ...
- java中的递归方法
一.含义 递归算法是一种直接或间接地调用自身的算法.在计算机编写程序中,递归算法对解决一大类问题是十分有效的,它往往使算法的描述简洁而且易于理解. 二.例子 99乘法表的例子 1:普通实现99乘法表太 ...
- windows 远程连接linux服务器
百度搜索“SSH Secure Shell Client” 并下载 2 点击Profiles选择add profiles 并添加profils名称 3 点击Profiles 填写远程linux的ip ...
- gulp + browserSync 一起提高前端开发效率吧!
前端开发的时候,每次修改代码后,要移动鼠标到浏览器选中再刷新查看效果,不知觉间我们的加班的时间又增加了0.5s, 真是罪孽!所以在使用gulp之后,就一直对能自动监听文件刷新页面的browserSyn ...
- Java之循环输出等腰三角形
public class aaa{ public static void main(String[] args) { int max=5; for(int i=1;i<=5;i++){//控制行 ...