pbootcms网站模板|日韩1区2区|织梦模板||网站源码|日韩1区2区|jquery建站特效-html5模板网

      <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="rzhjlrz" 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 委托函數(shù)調(diào)用了兩次

        PageViewController delegate functions called twice(PageViewController 委托函數(shù)調(diào)用了兩次)
          <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="vnpd57x" 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 委托函數(shù)調(diào)用了兩次的處理方法,對(duì)大家解決問題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

                  問題描述

                  限時(shí)送ChatGPT賬號(hào)..

                  我正在使用 UIPageViewController 為我的應(yīng)用程序制作產(chǎn)品導(dǎo)覽.

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

                  我點(diǎn)擊了這個(gè)鏈接 http://www.appcoda.com/uipageviewcontroller-tutorial-intro/

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

                  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;
                  }
                  

                  請(qǐng)幫幫我,我不知道哪里出錯(cuò)了

                  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 個(gè)函數(shù)用于獲取當(dāng)前 pageViewController 后面或前面的 pageViewController.

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

                  我認(rèn)為獲取當(dāng)前 pageViewController 很困難

                  I thinks it's difficult to get current pageViewController

                  我的建議:

                  在 UIPageViewControllerDelegate 中,它有一個(gè)功能:

                  In UIPageViewControllerDelegate, it have a function :

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

                  這個(gè)函數(shù)給你一個(gè)pendingViewControllers 數(shù)組和當(dāng)前pageViewController 數(shù)組.所以你可以這樣實(shí)現(xiàn):

                  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'函數(shù)中)

                  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];
                  }
                  

                  如果您有任何問題,請(qǐng)告訴我.

                  Let's me know if you have any questions.

                  這篇關(guān)于PageViewController 委托函數(shù)調(diào)用了兩次的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

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

                  相關(guān)文檔推薦

                  How to animate a UIImageview to display fullscreen by tapping on it?(如何通過點(diǎn)擊動(dòng)畫 UIImageview 以顯示全屏?)
                  To stop segue and show alert(停止 segue 并顯示警報(bào))
                  iOS 5 storyboard, programmatically determine path(iOS 5 故事板,以編程方式確定路徑)
                  Icon already includes gloss effects(圖標(biāo)已經(jīng)包含光澤效果)
                  How does UIEdgeInsetsMake work?(UIEdgeInsetsMake 是如何工作的?)
                  UIProgressView and Custom Track and Progress Images (iOS 5 properties)(UIProgressView 和自定義跟蹤和進(jìn)度圖像(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="b7frlxd" 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. 主站蜘蛛池模板: 桂林腻子粉_内墙外墙抗裂砂浆腻子粉推荐广西鑫达涂料厂家供应 | 神超官网_焊接圆锯片_高速钢锯片_硬质合金锯片_浙江神超锯业制造有限公司 | 植筋胶-粘钢胶-碳纤维布-碳纤维板-环氧砂浆-加固材料生产厂家-上海巧力建筑科技有限公司 | 对照品_中药对照品_标准品_对照药材_「格利普」高纯中药标准品厂家-成都格利普生物科技有限公司 澳门精准正版免费大全,2025新澳门全年免费,新澳天天开奖免费资料大全最新,新澳2025今晚开奖资料,新澳马今天最快最新图库 | 莱州网络公司|莱州网站建设|莱州网站优化|莱州阿里巴巴-莱州唯佳网络科技有限公司 | 盘扣式脚手架-附着式升降脚手架-移动脚手架,专ye承包服务商 - 苏州安踏脚手架工程有限公司 | 扒渣机厂家_扒渣机价格_矿用扒渣机_铣挖机_撬毛台车_襄阳永力通扒渣机公司 | 代理记账_免费注册公司_营业执照代办_资质代办-【乐财汇】 | 合肥办公室装修 - 合肥工装公司 - 天思装饰 | 超声波清洗机_细胞破碎仪_实验室超声仪器_恒温水浴-广东洁盟深那仪器 | 郑州外墙清洗_郑州玻璃幕墙清洗_郑州开荒保洁-河南三恒清洗服务有限公司 | 安驭邦官网-双向万能直角铣头,加工中心侧铣头,角度头[厂家直销] 闸阀_截止阀_止回阀「生产厂家」-上海卡比阀门有限公司 | 珠海网站建设_响应网站建设_珠海建站公司_珠海网站设计与制作_珠海网讯互联 | 室内室外厚型|超薄型|非膨胀型钢结构防火涂料_隧道专用防火涂料厂家|电话|价格|批发|施工 | 口信网(kousing.com) - 行业资讯_行业展会_行业培训_行业资料 | 北京征地律师,征地拆迁律师,专业拆迁律师,北京拆迁律师,征地纠纷律师,征地诉讼律师,征地拆迁补偿,拆迁律师 - 北京凯诺律师事务所 | 悬浮拼装地板_篮球场木地板翻新_运动木地板价格-上海越禾运动地板厂家 | 上海深蓝_缠绕机_缠膜机-上海深蓝机械装备有限公司 | 拉力机-万能试验机-材料拉伸试验机-电子拉力机-拉力试验机厂家-冲击试验机-苏州皖仪实验仪器有限公司 | 企典软件一站式企业管理平台,可私有、本地化部署!在线CRM客户关系管理系统|移动办公OA管理系统|HR人事管理系统|人力 | 防爆型气象站_农业气象站_校园气象站_农业四情监测系统「山东万象环境科技有限公司」 | 艾乐贝拉细胞研究中心 | 国家组织工程种子细胞库华南分库 | 英国雷迪地下管线探测仪-雷迪RD8100管线仪-多功能数字听漏仪-北京迪瑞进创科技有限公司 | 罗氏牛血清白蛋白,罗氏己糖激酶-上海嵘崴达实业有限公司 | 广东机电安装工程_中央空调工程_东莞装饰装修-广东粤标建设有限公司 | 京马网,京马建站,网站定制,营销型网站建设,东莞建站,东莞网站建设-首页-京马网 | 北京中创汇安科贸有限公司 | 照相馆预约系统,微信公众号摄影门店系统,影楼管理软件-盟百网络 | CCE素质教育博览会 | CCE素博会 | 教育展 | 美育展 | 科教展 | 素质教育展 | 东莞爱加真空科技有限公司-进口真空镀膜机|真空镀膜设备|Polycold维修厂家 | 东莞海恒试验仪器设备有限公司| 衬塑管道_衬四氟管道厂家-淄博恒固化工设备有限公司 | 专业的新乡振动筛厂家-振动筛品质保障-环保振动筛价格—新乡市德科筛分机械有限公司 | 雄松华章(广州华章MBA)官网-专注MBA/MPA/MPAcc/MEM辅导培训 | 山东信蓝建设有限公司官网 | 智能化的检漏仪_气密性测试仪_流量测试仪_流阻阻力测试仪_呼吸管快速检漏仪_连接器防水测试仪_车载镜头测试仪_奥图自动化科技 | 桥架-槽式电缆桥架-镀锌桥架-托盘式桥架 - 上海亮族电缆桥架制造有限公司 | 利浦顿蒸汽发生器厂家-电蒸汽发生器/燃气蒸汽发生器_湖北利浦顿热能科技有限公司官网 | Eiafans.com_环评爱好者 环评网|环评论坛|环评报告公示网|竣工环保验收公示网|环保验收报告公示网|环保自主验收公示|环评公示网|环保公示网|注册环评工程师|环境影响评价|环评师|规划环评|环评报告|环评考试网|环评论坛 - Powered by Discuz! | 温泉机设备|温泉小镇规划设计|碳酸泉设备 - 大连连邦温泉科技 | 污水处理设备,一体化泵站,一体化净水设备-「梦之洁环保设备厂家」 |