羊皮纸的奇怪滚动错误

问题描述

我们最近决定尝试将 Parchment 整合到我们的应用中,因为它非常适合我们的需求。 我们还添加一个折叠标题效果。 所以我们首先做了一个测试项目来测试它,就像我们将它重构到我们自己的应用程序一样,我们注意到一个非常奇怪的错误,我们似乎无法查明问题所在。 起初我们认为它可能是我们自己的应用程序中的东西,但我打开了测试项目,它也在那里。

此 GIF 将向您展示问题。当我们只有一个标签/屏幕时,情况更糟。然后甚至很难在不触发此问题的情况下向下滚动以正确刷新。

GIF

有人知道这可能发生的原因和地点吗?

Parchment 实现的示例代码

private var pagingViewController = PagingViewController()

pagingViewController.dataSource = self
pagingViewController.register(PagingCustomCell.self,for: CustomPagingItem.self)
addChild(pagingViewController)
pagingViewController.borderOptions = .hidden
pagingViewController.menuItemSize = .selfSizing(estimatedWidth: 100,height: 40)
pagingViewController.indicatorClass = CustomIndicatorView.self
pagingViewController.indicatorOptions = .visible(
    height: 32,zIndex: -1,spacing: .zero,insets: UIEdgeInsets(top: 0,left: 0,bottom: 5,right: 0)
)
pagingViewController.indicatorColor = .purple
pagingViewController.collectionView.contentInset = UIEdgeInsets(top: 0,left: 16,bottom: 0,right: 16)

view.addSubview(pagingViewController.view)
pagingViewController.backgroundColor = .clear
pagingViewController.didMove(toParent: self)
pagingViewController.view.translatesAutoresizingMaskIntoConstraints = false
pagingViewController.view.snp.makeConstraints { (m) in
    m.top.equalTo(headerView.snp.bottom)
    m.left.right.bottom.equalToSuperview()
}

// Put shadow beneath tabs for collapsing header
pagingViewController.collectionView.layer.masksToBounds = true
pagingViewController.collectionView.layer.shadowOffset = CGSize(width: 0,height: 1)
pagingViewController.collectionView.layer.shadowRadius = 1
pagingViewController.collectionView.layer.shadowOpacity = 0.3

extension ViewController: PagingViewControllerDataSource {
    
    func numberOfViewControllers(in pagingViewController: PagingViewController) -> Int {
        return pages.count
    }
    
    func pagingViewController(_: PagingViewController,viewControllerAt index: Int) -> UIViewController {
        let currentVc = pages[index]
        
        if let currentVc = currentVc {
            return currentVc
        } else {
            let tableViewVC = TableViewController()
            tableViewVC.innerTableViewScrollDelegate = self
            
            pages[index] = tableViewVC
            
            return tableViewVC
        }
    }
    
    func pagingViewController(_: PagingViewController,pagingItemAt index: Int) -> PagingItem {
        return CustomPagingItem(index: index,text: "View \(index+1)")
    }
}

解决方法

嗯,这不是真正的解决方案,但似乎这个问题在 2.4.0 版本中不存在,所以回滚到那个问题就消失了。我会继续留意未来的更新,然后看看它是否已修复。

Github post with answer