首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >UIPageViewController缓存

UIPageViewController缓存
EN

Stack Overflow用户
提问于 2014-06-04 10:01:14
回答 1查看 1.5K关注 0票数 1

我有一个带有数据源的UIPageViewController,它会动态地变化-

viewControllerAfterViewController

viewControllerBeforeViewController

如果数据尚未准备就绪,则返回零;如果数据准备就绪,则返回视图控制器。如果我试图在某个时候多次快速地向左转页面,viewControllerAfterViewController就不再被调用了。

有什么问题吗?我想UIPageViewController认为它什么都知道,什么都没有改变,所以它不调用该方法,对吗?我怎么能“重置”这个缓存?

我使用卷曲过渡风格,这似乎只发生在景观模式。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-06-08 01:21:40

最后我用了我自己的滑动手势。

  1. 首先,从UIPageViewController中删除现有的滑动手势 用于(UIGestureRecognizer *_pageViewController.gestureRecognizers中的识别器){ recognizer.enabled = NO;}
  2. 然后向UIPageViewController中添加您自己的滑动手势识别器 setDirection:(UISwipeGestureRecognizerDirectionLeft);* rightRecognizer = [UISwipeGestureRecognizer alloc initWithTarget:self action:@selector(handleRightSwipe:)];rightRecognizer UISwipeGestureRecognizer _pageViewController.view addGestureRecognizer:rightRecognizer;UISwipeGestureRecognizer * leftRecognizer = [UISwipeGestureRecognizer alloc initWithTarget:self action:@selector(handleLeftSwipe:)];leftRecognizer setDirection:(UISwipeGestureRecognizerDirectionRight);_pageViewController.view addGestureRecognizer:leftRecognizer;-(HandleRightSwipe):(id)发件人{ //您在这里的滑动处理程序//注意:您现在需要手动调用didFinishAnimating //手动计算next/prev控制器,还应该考虑方位太过UIViewController * nextController = _modelController pageViewController:_pageViewController __weak weakSelf = self;__weak UIPageViewController * wController = _pageViewController;[:@nextController方向:_pageViewController动画:YES:^(BOOL已完成){ [weakSelf页面查看控制器:wController已完成动画:YES previousViewController:@_pageViewController存在-控制器已完成:YES];};}}

另外,您可以尝试不删除现有的滑动手势,如果现有的识别器触发,它似乎不会调用您的自定义滑动手势,这样当您拖动页面的角时也会有很好的动画(如果删除所有识别器,它将丢失)。

票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/24034454

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档