UIPageViewController 实现从中间翻页效果
来源:互联网 发布:视频面试软件 编辑:程序博客网 时间:2024/06/10 05:03
最近两天一直在研究如何实现从中间翻页,问了很多人,也在网上查了很多资料,现在终于弄明白了。。。原来如此简单。。。
创建项目
启动Xcode,新建iOS Empty Application 项目
创建PageAppViewController
新建PageAppViewController项目,继承自UIPageViewController,如图:
PageViewController.h中代码如下:
#import <UIKit/UIKit.h>
@interface PageViewController :UIPageViewController<UIPageViewControllerDataSource,UIPageViewControllerDelegate>
@property(retain,nonatomic)NSArray * pageContent;
@property(retain,nonatomic)NSMutableArray * arr;
@end
PageViewController.m中代码:
#import "PageViewController.h"
@interface PageViewController ()
@end
@implementation PageViewController
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [superinitWithNibName:nibNameOrNilbundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewDidLoad
{
[superviewDidLoad];
// Do any additional setup after loading the view.
self.arr = [NSMutableArrayarrayWithCapacity:0];
[selfcreateContentPages];
self.dataSource =self;
self.delegate =self;
}
- (void)didReceiveMemoryWarning
{
[superdidReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (void)createContentPages{
for (int i =0; i <10; i ++) {
UIViewController * viewCtl = [[UIViewControlleralloc]init];
viewCtl.view.backgroundColor = [UIColorredColor];
[self.arraddObject:viewCtl];
}
[selfsetViewControllers:@[self.arr[0]]direction:(UIPageViewControllerNavigationDirectionForward)animated:NOcompletion:nil];
self.pageContent = [[NSArrayalloc]initWithArray:self.arr];
}
- (UIPageViewControllerSpineLocation)pageViewController:(UIPageViewController *)pageViewController spineLocationForInterfaceOrientation:(UIInterfaceOrientation)orientation{
NSArray * viewControllers =@[self.arr[0],self.arr[1]];
[selfsetViewControllers:viewControllersdirection:(UIPageViewControllerNavigationDirectionForward)animated:NOcompletion:nil];
returnUIPageViewControllerSpineLocationMid;
}
- (UIViewController *)pageViewController:(UIPageViewController *)pageViewController viewControllerAfterViewController:(UIViewController *)viewController{
int index = [self.arrindexOfObject:viewController];
if (index >=0 && index <self.arr.count -1) {
return [self.arrobjectAtIndex:index + 1];
}
return nil;
}
- (UIViewController *)pageViewController:(UIPageViewController *)pageViewController viewControllerBeforeViewController:(UIViewController *)viewController{
int index = [self.arrindexOfObject:viewController];
if (index >0 && index <self.arr.count -1) {
return [self.arrobjectAtIndex:index - 1];
}
return nil;
}
@end
- UIPageViewController 实现从中间翻页效果
- UIPageViewController实现书脊在中间的翻页效果
- iOS UIPageViewController模仿真实翻页效果
- ios教程lwxshow.com-PDF UIPageViewController实现翻页浏览
- UIPageViewController翻页背景改变
- UIPageViewController 禁用翻页手势
- PagerView实现翻页效果
- 实现Ajax翻页效果
- js实现翻页效果
- Android实现翻页效果
- transform3D实现翻页效果
- 翻页效果实现
- js翻页效果实现
- Android 实现 按钮从两边移到中间动画效果
- 网页翻页效果的实现
- 纯CSS实现翻页效果
- 翻页效果的动画实现
- Android 实现书籍翻页效果
- web性能测试工具ab
- 毛兴宇签名档
- Code Sign error: Provisioning profile ‘XXXX’ can't be found
- Java的反射机制
- php 时间处理(昨天 上个月 本月 最近7天)
- UIPageViewController 实现从中间翻页效果
- Play!
- IOS系列——添加image图片和对图片添加事件响应
- linux 启用root用户登录,启用root帐号和登录权限
- C++与C#的内存映射
- UVa 621 Secret Research (water ver.)
- Java中&和&&
- 为何“返回”按钮总是不显示
- VS2012关闭单击文件进行预览的功能