//
// 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:翻页效果的更多相关文章

  1. iOS:横向使用iPhone默认的翻页效果

    大致思路使用两层辅助UIView的旋转来实现添加后的View的横向翻页效果 CATransform3D transformA = CATransform3DRotate(CATransform3DId ...

  2. 关于Page翻页效果, PageViewConrtoller

    Page View Controllers你使用一个page view controller用page by page的方式来展示内容.一个page view controller管理一个self-c ...

  3. webapp应用--模拟电子书翻页效果

    前言: 现在移动互联网发展火热,手机上网的用户越来越多,甚至大有超过pc访问的趋势.所以,用web程序做出仿原生效果的移动应用,也变得越来越流行了.这种程序也就是我们常说的单页应用程序,它也有一个英文 ...

  4. 采用cocos2d-x lua 的listview 实现pageview的翻页效果之上下翻页效果

    --翻页滚动效果local function fnScrollViewScrolling( sender,eventType)    -- body    if eventType == 10 the ...

  5. css实现翻页效果

    如图,鼠标移动到图上,实现右上角翻页的效果,本例主要border边框的设置. 一.基本概念 <html> <head> <style> #demo{ width:0 ...

  6. turn.js 图书翻页效果

    今天用turn.js 做图书的翻页效果遇到问题: 图片路径总是出错 调了一天,总算调出来了 我用的thinkphp,其他的不知道是不是一样 三 个地方要改动: 1.后台查出地址 注意的地方:1.地址要 ...

  7. (旧)子数涵数·PS ——翻页效果

    一.首先在网络上下载一张图片,作为素材.这是我下载的素材,至于为什么选择这张照片呢,当然不是因为自己的一些羞羞的念头啦. 二.打开Photoshop,我使用的版本是CS3(因为CS3所占的磁盘空间较小 ...

  8. ajax翻页效果模仿yii框架

    ajax翻页效果,模仿yii框架. 复制代码代码如下: <!DOCTYPE html>  <html>  <head>  <title>ajax分页_w ...

  9. 纯css3写的仿真图书翻页效果

    对css3研究越深入,越觉得惊艳.css3说不上是万能的,但是它能实现的效果也超出了我的想象.它的高效率和动画效果的流畅性很多情况下能替代js的作用.个人习惯css3能实现的效果就不会用js,虽然在国 ...

随机推荐

  1. CSharp - Comparison between IComparer and IComparable

    /* Author: Jiangong SUN */ I've already written an article introducing the usage of comparer here. I ...

  2. DataTable导入到Excel文件

        ;                saveFileDialog.RestoreDirectory = ;            , intIndex] = column.ColumnName; ...

  3. memcpy的使用方法总结

    1.memcpy 函数用于 把资源内存(src所指向的内存区域) 复制到目标内存(dest所指向的内存区域):拷贝多少个?有一个size变量控制拷贝的字节数:函数原型:void *memcpy(voi ...

  4. VoltDB公布4.0版本号,大步提高内存实时分析速度,进军操作数据库市场

    号称世界上最快的关系数据库的VoltDB与2014年1月29号(美国东部时间)公布下一代数据库4.0版本号.新的版本号有非常多地方的改进,大步挺高系统性能.在过去的13年,VoltdDB号称自己公司较 ...

  5. Servlet中文乱码解决方法

    程序中的输入输出都是以流的形式保存的,流中保存的实际上全都是字节文件. 字节流和字符流的区别: 在Java.io包中操作文件内容的主要有两大类:字节流.字符流,两类都分为输入和输出操作. 在字节流中输 ...

  6. tem

    有时间需要整理的东西 1.登录 2.后台框架(管理界面) 3.api详细情况调用 4.具有基础操作的模块 5.session 6.操作权限控制

  7. Codeforces Round #310 (Div. 2)--B

    http://codeforces.com/problemset/problem/556/B 题意:给定n个数字且都小于n,然后每次循环第2k+1个数字+1,第2k个数字减一,k=0,1,2...n/ ...

  8. ( 转 )Github配置

    以下转自 http://liuzhijun.iteye.com/blog/1457207 有问题请联系我删除. -----———————————————————————— 如果你的代码不知道放哪里好, ...

  9. svn出错问题(用户名密码有修改以及资源url改变时)

    用eclipse 同步SVN服务器宛然无法访问了: org.tigris.subversion.javahl.ClientException: RA layer request failed svn: ...

  10. Navicat 看历史执行SQL

    Navicat可以通过这个框口看手动操作所执行的代码操作