您好,登录后才能下订单哦!
- (void)viewDidLoad
{
[super viewDidLoad];
[self createContentPages];// 初始化所有数据
// 设置UIPageViewController的配置项
NSDictionary *options =[NSDictionary dictionaryWithObject:[NSNumber numberWithInteger:UIPageViewControllerSpineLocationMin]
forKey: UIPageViewControllerOptionSpineLocationKey];
// 实例化UIPageViewController对象,根据给定的属性
self.pageController = [[UIPageViewController alloc] initWithTransitionStyle:UIPageViewControllerTransitionStylePageCurl
navigationOrientation:UIPageViewControllerNavigationOrientationHorizontal
options: options];
[[_pageController view] setFrame:[[self view] bounds]];
}
1.UIPageViewControllerDataSource协议
该协议主要有两个方法:
- (UIViewController *)pageViewController:(UIPageViewController *)pageViewController viewControllerBeforeViewController:(UIViewController *)viewController;
- (UIViewController *)pageViewController:(UIPageViewController *)pageViewController viewControllerAfterViewController:(UIViewController *)viewController;
分别用来提供UIPageViewController对象的数据源,即UIPageViewController对象通过该方法来调度显示的内容。
_pageController.dataSource = self;
2.初始化时,显示适当内容
MoreViewController *initialViewController =[self viewControllerAtIndex:0];// 得到第一页
NSArray *viewControllers =[NSArray arrayWithObject:initialViewController];
[_pageController setViewControllers:viewControllers
direction:UIPageViewControllerNavigationDirectionForward
animated:NO
completion:nil];
// 在页面上,显示UIPageViewController对象的View
[self addChildViewController:_pageController];
[[self view] addSubview:[_pageController view]];
3.准备好数据源
[self createContentPages];// 初始化所有数据
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。