欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

UIPageViewController實(shí)現(xiàn)的左右滑動界面

 更新時(shí)間:2018年06月30日 13:04:59   作者:Ittttttttta  
這篇文章主要為大家詳細(xì)介紹了UIPageViewController實(shí)現(xiàn)的左右滑動界面,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下

本文實(shí)例為大家分享了UIPageViewController實(shí)現(xiàn)左右滑動界面展示的具體代碼,供大家參考,具體內(nèi)容如下


.h

#import <UIKit/UIKit.h>
@interface ViewController : UIViewController

@end

.m

#import "ViewController.h"
#import "SubPage1ViewController.h"
#import "SubPage2ViewController.h"
@interface ViewController ()<UIPageViewControllerDataSource,UIPageViewControllerDelegate>
@property NSArray *contentViewControllers; //ViewControllers
@property (nonatomic, strong) UIPageViewController *pageViewController;
@end

@implementation ViewController

- (void)viewDidLoad {
  [super viewDidLoad];
  [self pageViewController];
}

- (void)didReceiveMemoryWarning {
  [super didReceiveMemoryWarning];
  // Dispose of any resources that can be recreated.
}
#pragma mark
#pragma mark ----- UIPageViewControllerDataSource -----
- (UIViewController *)pageViewController:(UIPageViewController *)pageViewController viewControllerBeforeViewController:(UIViewController *)viewController
{
  NSUInteger index = [self indexForViewController:viewController];
  if (index == 0) {
    index = [self.contentViewControllers count] - 1;
  } else {
    index--;
  }
  return [self viewControllerAtIndex:index];
}
- (UIViewController *)pageViewController:(UIPageViewController *)pageViewController viewControllerAfterViewController:(UIViewController *)viewController
{
  NSUInteger index = [self indexForViewController:viewController];
  index++;
  if (index == [self.contentViewControllers count]) {
    index = 0;
  }
  return [self viewControllerAtIndex:index];
}
- (NSUInteger)indexForViewController:(UIViewController *)viewController
{
  return [self.contentViewControllers indexOfObject:viewController];
}

- (UIViewController *)viewControllerAtIndex:(NSUInteger)index
{
  if (index > [self.contentViewControllers count]) {
    return nil;
  }
  UIViewController *vc = [self.contentViewControllers objectAtIndex:index];
  return vc;
}
#pragma mark
#pragma mark ----- UIPageViewControllerDelegate -----
- (void)pageViewController:(UIPageViewController *)pageViewController willTransitionToViewControllers:(NSArray *)pendingViewControllers
{


}
- (void)pageViewController:(UIPageViewController *)pageViewController didFinishAnimating:(BOOL)finished previousViewControllers:(NSArray *)previousViewControllers transitionCompleted:(BOOL)completed
{
}
#pragma mark
#pragma mark Init
- (UIPageViewController *)pageViewController
{
  if(!_pageViewController)
  {
    NSDictionary *options =[NSDictionary dictionaryWithObject:[NSNumber numberWithInteger:UIPageViewControllerSpineLocationMin]
                              forKey: UIPageViewControllerOptionSpineLocationKey];
    _pageViewController = [[UIPageViewController alloc] initWithTransitionStyle:UIPageViewControllerTransitionStyleScroll
                               navigationOrientation:UIPageViewControllerNavigationOrientationHorizontal
                                      options:options];
    [[_pageViewController view] setFrame:[[self view] bounds]];
    _contentViewControllers = [NSMutableArray arrayWithObjects:[SubPage1ViewController new],[SubPage2ViewController new],nil];
    // 設(shè)置UIPageViewController的配置項(xiàng)
    [_pageViewController setViewControllers:[NSArray arrayWithObjects:_contentViewControllers[0], nil]
                   direction:UIPageViewControllerNavigationDirectionForward
                    animated:NO
                   completion:nil];
    _pageViewController.delegate = self;
    _pageViewController.dataSource = self;
    [self addChildViewController:self.pageViewController];
    [self.view addSubview:self.pageViewController.view];

  }
  return _pageViewController;

}

以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

  • iOS中的NSTimer定時(shí)器的初步使用解析

    iOS中的NSTimer定時(shí)器的初步使用解析

    這篇文章主要介紹了iOS中的NSTimer定時(shí)器的初步使用解析,通過例子簡單講解了NSTimer的輸出與停止的方法,需要的朋友可以參考下
    2016-05-05
  • IOS 遠(yuǎn)程通知兼容(IOS7,IOS8)實(shí)例詳解

    IOS 遠(yuǎn)程通知兼容(IOS7,IOS8)實(shí)例詳解

    這篇文章主要介紹了IOS 遠(yuǎn)程通知兼容(IOS7,IOS8)實(shí)例詳解的相關(guān)資料,需要的朋友可以參考下
    2017-03-03
  • iOS 使用Moya網(wǎng)絡(luò)請求的實(shí)現(xiàn)方法

    iOS 使用Moya網(wǎng)絡(luò)請求的實(shí)現(xiàn)方法

    這篇文章主要介紹了iOS 使用Moya網(wǎng)絡(luò)請求的實(shí)現(xiàn)方法,小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧
    2018-07-07
  • iOS開發(fā)傻瓜式微信支付的方法教程

    iOS開發(fā)傻瓜式微信支付的方法教程

    最近因?yàn)楣ぷ鞯男枰?,要開發(fā)微信支付,發(fā)現(xiàn)網(wǎng)上的很多教程過于復(fù)雜,索性自己寫一篇,所以下面這篇文章主要跟大家分享了關(guān)于iOS開發(fā)傻瓜式微信支付的方法教程,文中通過示例代碼介紹的非常詳細(xì),需要的朋友們下面來一起看看吧。
    2017-07-07
  • iOS報(bào)Multiple?commands?produceMultiple錯(cuò)誤的解決方案

    iOS報(bào)Multiple?commands?produceMultiple錯(cuò)誤的解決方案

    這篇文章主要為大家介紹了iOS報(bào)Multiple?commands?produceMultiple錯(cuò)誤的解決方案,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪
    2023-11-11
  • iOS多Target環(huán)境配置的完整步驟

    iOS多Target環(huán)境配置的完整步驟

    這篇文章主要給大家介紹了關(guān)于iOS多Target環(huán)境配置的完整步驟,文中通過示例代碼介紹的非常詳細(xì),對各位iOS開發(fā)者們具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面來一起學(xué)習(xí)學(xué)習(xí)吧
    2019-10-10
  • iOS App開發(fā)中通過UIDevice類獲取設(shè)備信息的方法

    iOS App開發(fā)中通過UIDevice類獲取設(shè)備信息的方法

    UIDevice最常見的用法就是用來監(jiān)測iOS設(shè)備的電量了,然后再實(shí)現(xiàn)電池狀態(tài)通知非常方便,除此之外還有傳感器等信息的獲取,這里我們就來總結(jié)一下iOS App開發(fā)中通過UIDevice類獲取設(shè)備信息的方法:
    2016-07-07
  • 詳解優(yōu)化iOS程序性能的25個(gè)方法

    詳解優(yōu)化iOS程序性能的25個(gè)方法

    本篇文章主要介紹了優(yōu)化iOS程序性能的25個(gè)方法,小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧
    2016-12-12
  • iOS內(nèi)存管理引用計(jì)數(shù)示例分析

    iOS內(nèi)存管理引用計(jì)數(shù)示例分析

    這篇文章主要為大家介紹了iOS內(nèi)存管理引用計(jì)數(shù)示例分析詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪
    2023-01-01
  • iOS 圖片上傳使用base64或者二進(jìn)制流上傳頭像功能

    iOS 圖片上傳使用base64或者二進(jìn)制流上傳頭像功能

    這篇文章主要介紹了iOS 圖片上傳使用base64或者二進(jìn)制流上傳頭像功能,需要的朋友可以參考下
    2017-09-09

最新評論