UIQueuingScrollView中的断言失败didScrollWithAnimation:force: [英] Assertion failure in UIQueuingScrollView didScrollWithAnimation:force:

查看:393
本文介绍了UIQueuingScrollView中的断言失败didScrollWithAnimation:force:的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 UIPageViewController 设置分页我的 ImageViewController

I've got a UIPageViewController set up paging my ImageViewController.

ImageViewController 包含 UIScrollView ,带有 UIImageView 里面。没有别的。

The ImageViewController contains a UIScrollView with a UIImageView inside. Nothing else.

我正在测试我的数据源中的3个项目,用于 UIPageViewController (即三页)。

I'm testing at the moment with 3 "items" in my datasource for the UIPageViewController (i.e. three pages).

一切正常,我可以滚动和缩放然后翻页大约30秒然后我突然得到这个警告...

It all works fine and I can scroll and zoom and then page for about 30 seconds and then suddenly I get this warning...

*** Assertion failure in -[_UIQueuingScrollView _didScrollWithAnimation:force:], /SourceCache/UIKit/UIKit-2372/_UIQueuingScrollView.m:778

我不知道从哪里开始调试它因为它没有指向任何我的代码并没有我的任何代码在堆栈或任何东西。

I've got no idea where to start debugging it though as it doesn't point to any of my code and there isn't any of my code in the stack or anything.

有人可以给我一个指针,指出从哪里开始调试。

Can someone give me a pointer as to where to start debugging this.

编辑

我做了一些测试。如果scrollView正在减速(即在轻弹之后)似乎会发生,然后我尝试将PageViewController转换到另一个ViewController,因为scrollview仍在移动。

I've done a bit more testing. It seems to happen if the scrollView is decelerating (i.e. after a flick) and then I try to transition the PageViewController to another ViewController as the scrollview is still moving.

该应用程序在转换到下一页的过程中大约有20%崩溃。

The app crashes about 20% of the way through the transition to the next page.

编辑2

错误似乎停在_cache_getImp行上(不确定这是大写字母i还是小写字母L)。

The error seems to stop on the line _cache_getImp (not sure if that's a capital i or lowercase L).

编辑3

这会变得更好。我刚刚下载了Apple的PhotoScroller示例应用程序,看看他们是否以不同的方式解决了问题。嗯,不,他们没有。示例应用程序以与我的方式完全相同的方式崩溃!你必须同时缩放,滚动和转换页面,以使其更容易崩溃,但它也可能发生在它自己也可能需要更长的时间。

This gets better. I just downloaded Apple's PhotoScroller sample app to see if they got round the problem a different way. Well, no, they didn't. The sample app crashes in exactly the same way mine does! You have to zoom and scroll and transition pages at the same time to make it more likely to crash but it happens on it's own too it just might take longer to happen.

推荐答案

想出一个解决方案!在我的情况下,我有一个 UIPageViewController UIPageViewControllerTransitionStyleScroll 以及允许用户通过我的viewpager前进的下一个按钮窃听。当用户按下下一个按钮并在释放他们的手指之前稍微拖动(仍然在按钮的框架内)时,我得到了这个崩溃。在这种情况下,按钮内的拖动似乎会干扰 UIPageViewController 的平移手势识别器,这就是导致崩溃的原因。

Came up with a solution! In my case I have a UIPageViewController with UIPageViewControllerTransitionStyleScroll as well as next buttons that allow the user to advance through my viewpager by tapping. I am getting this crash when the user presses a next button and drags around slightly before releasing their finger (still within the frame of the button). It appears that the dragging within the button is interfering with UIPageViewController's pan gesture recognizer in this case, and that's what causes the crash.

虽然用户不太可能进入这种状态,但我已经提出了一个相对简单的解决方案,可以防止我的应用程序崩溃。我有一个布尔值,表示用户是否处于有效状态以移动到下一个屏幕并在触摸时将其设置为YES,如果用户拖动到我的按钮内的任何位置则为NO。然后,在touchUp(nextPressed)上,我以编程方式移动我的 UIPageViewController 之前检查布尔值。

While it's pretty unlikely that the user will get in this state, I've come up with a relatively simple solution the prevents my app from crashing if it does happen. I have a boolean that represents if the user is in a valid state to move to the next screen and set it to YES on touch down, then to NO if the user drags anywhere inside my button. Then, on touchUp (nextPressed) I check the boolean before moving my UIPageViewController programatically.

- (IBAction)touchDown:(id)sender
{
  self.shouldAdvanceToNextScreen = YES;
}

- (IBAction)touchDragInside:(id)sender
{
  self.shouldAdvanceToNextScreen = NO;
}

- (IBAction)nextPressed:(id)sender
{
  if (self.shouldAdvanceToNextScreen) {
    UIViewController *initialViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"TutorialScreen2"];
    NSArray *viewControllers = [NSArray arrayWithObject:initialViewController];
    [self.pageViewController setViewControllers:viewControllers direction:UIPageViewControllerNavigationDirectionForward animated:YES completion:nil];
  }
}

缺点是即使用户也不会发生任何事情仍然将手指放在按钮框架内。但是,我更倾向于崩溃,并将此视为一种非常罕见的边缘情况。我希望用户可以再次点击 - 这次没有点击和放大拖动 - 并成功向前移动。

The downside is that nothing will happen even though the user still released their finger within the button frame. However, I prefer this over a crash and see this as a pretty rare edge case regardless. I'd expect the user would just tap again - this time without a tap & drag - and move forward successfully.

我欢迎任何有关进一步采取措施并避免触摸拖动与之间冲突的想法UIPageViewController 一共。

I'd welcome any ideas on taking this a step further and preventing the clash between the touch drag and the UIPageViewController altogether.

这篇关于UIQueuingScrollView中的断言失败didScrollWithAnimation:force:的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆