最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

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

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

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


.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];
    // 設置UIPageViewController的配置項
    [_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;

}

以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持腳本之家。

相關文章

  • iOS 仿微博客戶端紅包加載界面 XLDotLoading效果

    iOS 仿微博客戶端紅包加載界面 XLDotLoading效果

    這篇文章主要介紹了iOS 仿微博客戶端紅包加載界面 XLDotLoading,需要的朋友可以參考下
    2017-02-02
  • iOS開發(fā)實現(xiàn)搜索框(UISearchController)

    iOS開發(fā)實現(xiàn)搜索框(UISearchController)

    這篇文章主要為大家詳細介紹了iOS開發(fā)實現(xiàn)搜索框,文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2022-08-08
  • iOS實現(xiàn)雷達掃描效果

    iOS實現(xiàn)雷達掃描效果

    這篇文章主要為大家詳細介紹了iOS實現(xiàn)雷達掃描效果,文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2021-10-10
  • iOS UISegmentControl實現(xiàn)自定義分欄效果

    iOS UISegmentControl實現(xiàn)自定義分欄效果

    這篇文章主要為大家詳細介紹了iOS UISegmentControl實現(xiàn)自定義分欄效果,文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2022-03-03
  • iOS中sqlite的詳細用法

    iOS中sqlite的詳細用法

    在iOS中,也同樣支持sqlite。目前有很多第三方庫,封裝了sqlite操作,比如swift語言寫的SQLite.swift,對sqlite感興趣的小伙伴們可以參考一下
    2016-05-05
  • iOS 對象屬性詳細介紹

    iOS 對象屬性詳細介紹

    這篇文章主要介紹了iOS 對象屬性詳細介紹的相關資料,這里整理了IOS 對象的相關資料,需要的朋友可以參考下
    2016-11-11
  • iOS常見算法以及應用知識點總結

    iOS常見算法以及應用知識點總結

    在本篇文章里小編給大家分享的是關于iOS常見算法以及應用知識點總結,有興趣的朋友們學習下。
    2019-10-10
  • IOS 實現(xiàn)一個死鎖導致 UI 假死的例子

    IOS 實現(xiàn)一個死鎖導致 UI 假死的例子

    這篇文章主要介紹了IOS 實現(xiàn)一個死鎖導致 UI 假死的例子的相關資料,需要的朋友可以參考下
    2016-12-12
  • 詳談iPhoneX截圖如何帶

    詳談iPhoneX截圖如何帶

    下面小編就為大家分享一篇詳談iPhoneX截圖如何帶"劉海"和圓角,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧
    2018-01-01
  • iOS開發(fā)自定義頁腳和頁眉技巧詳解

    iOS開發(fā)自定義頁腳和頁眉技巧詳解

    這篇文章主要為大家介紹了iOS開發(fā)自定義頁腳和頁眉的技巧示例詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進步,早日升職加薪
    2022-07-07

最新評論

伊川县| 河南省| 乳源| 大足县| 乌鲁木齐县| 昂仁县| 凤山县| 乌什县| 武夷山市| 海阳市| 六盘水市| 丰镇市| 闸北区| 鄄城县| 雷州市| 霍林郭勒市| 大新县| 东山县| 阜阳市| 潜山县| 仪征市| 五原县| 沈阳市| 曲周县| 共和县| 彰化县| 台北县| 普宁市| 南宁市| 长丰县| 张家港市| 长治市| 城口县| 濮阳县| 河间市| 天门市| 晋中市| 马鞍山市| 大连市| 东海县| 清涧县|