mat*_*att 45 uipageviewcontroller ios6
我的UIPageViewController在iOS 5中运行良好.但是当iOS 6出现时,我想使用新的滚动转换样式(UIPageViewControllerTransitionStyleScroll)而不是页面卷曲样式.这导致我的UIPageViewController破坏.
在我打电话之后,它工作得很好setViewControllers:direction:animated:completion:.之后,下次用户手动滚动一页时,我们会得到错误的页面.这有什么不对?
Geo*_*kas 77
我对此错误的解决方法是在完成时创建一个块,即设置相同的viewcontroller但没有动画
__weak YourSelfClass *blocksafeSelf = self;
[self.pageViewController setViewControllers:viewControllers direction:UIPageViewControllerNavigationDirectionForward animated:YES completion:^(BOOL finished){
if(finished)
{
dispatch_async(dispatch_get_main_queue(), ^{
[blocksafeSelf.pageViewController setViewControllers:viewControllers direction:UIPageViewControllerNavigationDirectionForward animated:NO completion:NULL];// bug fix for uipageview controller
});
}
}];
Run Code Online (Sandbox Code Playgroud)
mat*_*att 58
这实际上是UIPageViewController中的一个错误.它仅在滚动样式(UIPageViewControllerTransitionStyleScroll)中发生,并且仅在setViewControllers:direction:animated:completion: 使用动画调用后:YES.因此有两种解决方法:
不要使用UIPageViewControllerTransitionStyleScroll.
或者,如果您打电话setViewControllers:direction:animated:completion:,请仅使用animated:NO.
要清楚地看到错误,请setViewControllers:direction:animated:completion:在界面(作为用户)中调用,然后手动向左(向后)导航到上一页.您将导航回错误的页面:根本不是前一页,而是setViewControllers:direction:animated:completion:调用时所在的页面.
出现错误的原因似乎是,当使用滚动样式时,UIPageViewController会执行某种内部缓存.因此,在调用之后setViewControllers:direction:animated:completion:,它无法清除其内部缓存.它认为它知道前一页是什么.因此,当用户向左导航到前一页时,UIPageViewController 无法调用dataSource方法pageViewController:viewControllerBeforeViewController:,或者使用错误的当前视图控制器调用它.
我发布了一部电影,清楚地演示了如何查看错误:
http://www.apeth.com/PageViewControllerBug.mov
编辑此错误可能会在iOS 8中修复.
编辑有关此错误的另一个有趣的解决方法,请参阅以下答案:https://stackoverflow.com/a/21624169/341994
| 归档时间: |
|
| 查看次数: |
23675 次 |
| 最近记录: |