久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

      <legend id='qQz9v'><style id='qQz9v'><dir id='qQz9v'><q id='qQz9v'></q></dir></style></legend>
    1. <i id='qQz9v'><tr id='qQz9v'><dt id='qQz9v'><q id='qQz9v'><span id='qQz9v'><b id='qQz9v'><form id='qQz9v'><ins id='qQz9v'></ins><ul id='qQz9v'></ul><sub id='qQz9v'></sub></form><legend id='qQz9v'></legend><bdo id='qQz9v'><pre id='qQz9v'><center id='qQz9v'></center></pre></bdo></b><th id='qQz9v'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='qQz9v'><tfoot id='qQz9v'></tfoot><dl id='qQz9v'><fieldset id='qQz9v'></fieldset></dl></div>

      <small id='qQz9v'></small><noframes id='qQz9v'>

        <bdo id='qQz9v'></bdo><ul id='qQz9v'></ul>

      1. <tfoot id='qQz9v'></tfoot>

        PageViewController 委托函數調用了兩次

        PageViewController delegate functions called twice(PageViewController 委托函數調用了兩次)
          <tbody id='7BwOT'></tbody>

        • <i id='7BwOT'><tr id='7BwOT'><dt id='7BwOT'><q id='7BwOT'><span id='7BwOT'><b id='7BwOT'><form id='7BwOT'><ins id='7BwOT'></ins><ul id='7BwOT'></ul><sub id='7BwOT'></sub></form><legend id='7BwOT'></legend><bdo id='7BwOT'><pre id='7BwOT'><center id='7BwOT'></center></pre></bdo></b><th id='7BwOT'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='7BwOT'><tfoot id='7BwOT'></tfoot><dl id='7BwOT'><fieldset id='7BwOT'></fieldset></dl></div>

            <legend id='7BwOT'><style id='7BwOT'><dir id='7BwOT'><q id='7BwOT'></q></dir></style></legend>
              <bdo id='7BwOT'></bdo><ul id='7BwOT'></ul>
            • <small id='7BwOT'></small><noframes id='7BwOT'>

              1. <tfoot id='7BwOT'></tfoot>
                • 本文介紹了PageViewController 委托函數調用了兩次的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  限時送ChatGPT賬號..

                  我正在使用 UIPageViewController 為我的應用程序制作產品導覽.

                  I am working with UIPageViewController , to make a product tour for my application.

                  我點擊了這個鏈接 http://www.appcoda.com/uipageviewcontroller-tutorial-intro/

                  我正在做的是根據我得到的索引值在滑動時更改 root VC" 的背景顏色的簡單任務,但是由于委托函數被調用兩次,我的索引值是不正確,因此,我無法正確處理,下面是我的代碼

                  I am doing is simple task of changing backgound color of my "root VC" on swipe, based on the index value I get, but as the delegate functions are called twice, my index value is not correct and because of that, I am not able to get it right, below is my code

                  #import "APPViewController.h"
                  #import "APPChildViewController.h"
                  
                  @interface APPViewController ()
                  
                  @end
                  
                  @implementation APPViewController
                  
                  - (void)viewDidLoad {
                  
                      [super viewDidLoad];
                  
                      self.pageController = [[UIPageViewController alloc] initWithTransitionStyle:UIPageViewControllerTransitionStyleScroll navigationOrientation:UIPageViewControllerNavigationOrientationHorizontal options:nil];
                  
                      self.pageController.dataSource = self;
                      [[self.pageController view] setFrame:CGRectMake(0, 0, 320, 500)];
                  
                      APPChildViewController *initialViewController = [self viewControllerAtIndex:0];
                  
                      NSArray *viewControllers = [NSArray arrayWithObject:initialViewController];
                  
                      [self.pageController setViewControllers:viewControllers direction:UIPageViewControllerNavigationDirectionForward animated:NO completion:nil];
                  
                      [self addChildViewController:self.pageController];
                      [[self view] addSubview:[self.pageController view]];
                      [self.pageController didMoveToParentViewController:self];
                  
                  }
                  
                  - (void)didReceiveMemoryWarning {
                  
                      [super didReceiveMemoryWarning];
                      // Dispose of any resources that can be recreated.
                  
                  }
                  
                  - (APPChildViewController *)viewControllerAtIndex:(NSUInteger)index {
                  
                      APPChildViewController *childViewController = [[APPChildViewController alloc] initWithNibName:@"APPChildViewController" bundle:nil];
                      childViewController.index = index;
                      childViewController.view.backgroundColor = [UIColor clearColor];
                  
                      if(index == 0)
                      {
                            self.view.backgroundColor = [UIColor redColor];
                       }
                  
                      if(index == 1)
                      {
                            self.view.backgroundColor = [UIColor blueColor];
                       }
                  
                      if(index == 2)
                      {
                            self.view.backgroundColor = [UIColor greenColor];
                       }
                  
                  
                      return childViewController;
                  
                  }
                  
                  - (UIViewController *)pageViewController:(UIPageViewController *)pageViewController viewControllerBeforeViewController:(UIViewController *)viewController {
                  
                      NSUInteger index = [(APPChildViewController *)viewController index];
                  
                      if (index == 0) {
                          return nil;
                      }
                  
                      // Decrease the index by 1 to return
                      index--;
                  
                     return [self viewControllerAtIndex:index];
                  
                  }
                  
                  - (UIViewController *)pageViewController:(UIPageViewController *)pageViewController viewControllerAfterViewController:(UIViewController *)viewController {
                  
                      NSUInteger index = [(APPChildViewController *)viewController index];
                  
                      index++;
                  
                      if (index == 3) {
                          return nil;
                      }
                  
                     return [self viewControllerAtIndex:index];
                  
                  }
                  
                  - (NSInteger)presentationCountForPageViewController:(UIPageViewController *)pageViewController {
                      // The number of items reflected in the page indicator.
                      return 3;
                  }
                  
                  - (NSInteger)presentationIndexForPageViewController:(UIPageViewController *)pageViewController {
                      // The selected item reflected in the page indicator.
                      return 0;
                  }
                  

                  請幫幫我,我不知道哪里出錯了

                  Please help me out, I am not getting where I am going wrong

                  問候蘭吉特

                  推薦答案

                  找了很多.

                  我收到了:

                  - (UIViewController *)pageViewController:(UIPageViewController *)pageViewController viewControllerBeforeViewController:(UIViewController *)viewController;
                  - (UIViewController *)pageViewController:(UIPageViewController *)pageViewController viewControllerAfterViewController:(UIViewController *)viewController;
                  

                  2 個函數用于獲取當前 pageViewController 后面或前面的 pageViewController.

                  2 functions use to get pageViewController behind or in front of current pageViewController.

                  我認為獲取當前 pageViewController 很困難

                  I thinks it's difficult to get current pageViewController

                  我的建議:

                  在 UIPageViewControllerDelegate 中,它有一個功能:

                  In UIPageViewControllerDelegate, it have a function :

                   - (void)pageViewController:(UIPageViewController *)pageViewController willTransitionToViewControllers:(NSArray *)pendingViewControllers;
                  

                  這個函數給你一個pendingViewControllers 數組和當前pageViewController 數組.所以你可以這樣實現:

                  This function to give you a pendingViewControllers array and this's current pageViewController array. So you can implement like that :

                  - (void)pageViewController:(UIPageViewController *)pageViewController willTransitionToViewControllers:(NSArray *)pendingViewControllers
                  {
                  
                  
                  if([pendingViewControllers count]>0)
                    {
                       NSUInteger index =[(APPChildViewController*)[pendingViewControllers objectAtIndex:0] index];
                  
                      if(index == 0)
                      {
                          self.view.backgroundColor = [UIColor redColor];
                      }
                  
                      if(index == 1)
                      {
                          self.view.backgroundColor = [UIColor blueColor];
                      }
                  
                      if(index == 2)
                      {
                          self.view.backgroundColor = [UIColor greenColor];
                      }
                  
                  
                    }
                  }
                  

                  在 viewDidLoad 中,添加:

                  In viewDidLoad, you add :

                      self.pageController.delegate = self;
                  
                      self.view.backgroundColor = [UIColor redColor]; //set first background.
                  

                  在 'APPViewController.h' 中你確定添加:

                  In 'APPViewController.h' you sure add:

                  @interface APPViewController : UIViewController<UIPageViewControllerDataSource,UIPageViewControllerDelegate>
                  

                  記住:刪除這段代碼(在'viewControllerAtIndex'函數中)

                  Remember : remove this code (in 'viewControllerAtIndex' function)

                  if(index == 1)
                  {
                      self.view.backgroundColor = [UIColor redColor];
                  }
                  
                  if(index == 2)
                  {
                      self.view.backgroundColor = [UIColor blueColor];
                  }
                  
                  if(index == 3)
                  {
                      self.view.backgroundColor = [UIColor greenColor];
                  }
                  

                  如果您有任何問題,請告訴我.

                  Let's me know if you have any questions.

                  這篇關于PageViewController 委托函數調用了兩次的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                  【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

                  相關文檔推薦

                  How to animate a UIImageview to display fullscreen by tapping on it?(如何通過點擊動畫 UIImageview 以顯示全屏?)
                  To stop segue and show alert(停止 segue 并顯示警報)
                  iOS 5 storyboard, programmatically determine path(iOS 5 故事板,以編程方式確定路徑)
                  Icon already includes gloss effects(圖標已經包含光澤效果)
                  How does UIEdgeInsetsMake work?(UIEdgeInsetsMake 是如何工作的?)
                  UIProgressView and Custom Track and Progress Images (iOS 5 properties)(UIProgressView 和自定義跟蹤和進度圖像(iOS 5 屬性))

                    <tfoot id='Cld3g'></tfoot>

                    1. <i id='Cld3g'><tr id='Cld3g'><dt id='Cld3g'><q id='Cld3g'><span id='Cld3g'><b id='Cld3g'><form id='Cld3g'><ins id='Cld3g'></ins><ul id='Cld3g'></ul><sub id='Cld3g'></sub></form><legend id='Cld3g'></legend><bdo id='Cld3g'><pre id='Cld3g'><center id='Cld3g'></center></pre></bdo></b><th id='Cld3g'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='Cld3g'><tfoot id='Cld3g'></tfoot><dl id='Cld3g'><fieldset id='Cld3g'></fieldset></dl></div>

                      <small id='Cld3g'></small><noframes id='Cld3g'>

                        <bdo id='Cld3g'></bdo><ul id='Cld3g'></ul>
                        <legend id='Cld3g'><style id='Cld3g'><dir id='Cld3g'><q id='Cld3g'></q></dir></style></legend>
                          <tbody id='Cld3g'></tbody>
                          1. 主站蜘蛛池模板: 人人草天天草 | 国产精品a久久久久 | 黄视频免费| 日韩欧美中文 | 91在线观看视频 | 欧美一区二区免费 | 国产成人精品久久二区二区 | 中文字幕一区二区三区四区五区 | 嫩草视频入口 | 国产91在线播放精品91 | 中文字幕1区2区3区 亚洲国产成人精品女人久久久 | 在线激情视频 | 国产婷婷在线视频 | 美女天天操 | 久久这里只有 | 亚洲精品国产成人 | 中文字幕视频三区 | 国产精品区二区三区日本 | 欧美激情一区 | 午夜免费网 | 亚洲精品视频免费 | 亚洲欧美精品久久 | 国产视频精品在线观看 | 亚洲毛片在线观看 | 久久国产成人精品国产成人亚洲 | 欧美日韩在线观看一区 | 国产精品国产精品国产专区不卡 | 一级做a爰片久久毛片免费看 | 国产精品久久久久久久久久久久冷 | 一区二区三区中文字幕 | 日本网站免费观看 | 日韩欧美在线视频 | 精品久久久久久久久久久下田 | 欧美一区二区免费电影 | 久久av一区二区三区 | 久久久青草婷婷精品综合日韩 | 久草免费福利 | 国产精品久久久久久久久久久久久 | 久久机热 | 欧美日韩免费 | 久久久久国产一区二区三区 |