ios – UIPageViewController转换’不平衡调用开始/结束外观转换’

前端之家收集整理的这篇文章主要介绍了ios – UIPageViewController转换’不平衡调用开始/结束外观转换’前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
当我通过UIPageViewController浏览速度超过其转换动画时,我得到“MyDataViewController>”的不平衡调用开始/结束外观转换并且在我尝试翻页之前,不会显示景观中的两个视图之一.

任何人有一个想法来解决这个bug?

解决方法

上面的答案是正确的,但我认为比需要更精细,食谱是有帮助的.所以这里似乎是为我工作的:

在设置并调用pageViewController的视图控制器中,
宣布:

@property (assign)              BOOL pageIsAnimating;

并在viewDidLoad:

pageIsAnimating = NO;

加这个:

- (void)pageViewController:(UIPageViewController *)pageViewController willTransitionToViewControllers:(NSArray *)pendingViewControllers {
    pageIsAnimating = YES;
}

添加几行:

- (void)pageViewController:(UIPageViewController *)pageViewController
    didFinishAnimating:(BOOL)finished prevIoUsViewControllers:(NSArray *)prevIoUsViewControllers
   transitionCompleted:(BOOL)completed {
    if (completed || finished)   // Turn is either finished or aborted
        pageIsAnimating = NO;
    ...
}

手势被拒绝提供视图控制器信息被抑制:

- (UIViewController *)pageViewController:(UIPageViewController *)pageViewController
   viewControllerAfterViewController:(UIViewController *)viewController {
    if (pageIsAnimating)
        return nil;
    ...
    return after;
}

- (UIViewController *)pageViewController:(UIPageViewController *)pageViewController
  viewControllerBeforeViewController:(UIViewController *)viewController {
    if (pageIsAnimating)
        return nil;
    ...
    return before;
}

哦,方向改变重置标志:

- (UIPageViewControllerSpineLocation)pageViewController:(UIPageViewController *)pageViewController
               spineLocationForInterfaceOrientation:(UIInterfaceOrientation)orientation {
    pageIsAnimating = NO;
    ...
}
原文链接:https://www.f2er.com/iOS/336664.html

猜你在找的iOS相关文章