Assertion failure in UIQueuingScrollView didScrollWithAnimation:force:

后端 未结 5 1306
情深已故
情深已故 2021-01-31 03:17

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

The ImageViewController contains a UIScrollView

5条回答
  •  深忆病人
    2021-01-31 03:56

    I had a similar problem. My setup was a UIPageViewController and I was loading view controllers with an UIImageView inside. When interacting while the UIPageViewController was scrolling I got the same crash log.

    I fixed it by creating a UILongPressGestureRecognizer and add to the UIPageViewController's scroll view.

    1. Created my own subclass of UIPageViewController (Solution is specific for my case but can easily used as a generic solution)

    2. Find the inner UIScrollView of the UIPageViewController

      - (UIScrollView *)findScrollView
      {
          UIScrollView *scrollView;
          for (id subview in self.view.subviews)
          {
              if ([subview isKindOfClass:UIScrollView.class])
              {
                  scrollView = subview;
                  break;
              }
          }
      
          return scrollView;
      }
      
    3. Add the long tap gesture recognizer to the inner scroll view and point its action to a method or nil

      /**
       *  On tap-hold the page view controller crashes as soon as it pages to a new view controller.
       *  Setting a long press gesture to ignore the hold.
       */
      - (void)listenForLongPressGestureOnScrollView:(UIScrollView *)scrollView
      {
          UILongPressGestureRecognizer *longPressGestureRecognizer = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:nil];
          [longPressGestureRecognizer setMinimumPressDuration:0.5];
          [scrollView addGestureRecognizer:longPressGestureRecognizer];
      }
      

提交回复
热议问题