Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NSInternalInconsistencyException,这个Bug复现率有点高。 #268

Open
developerjet opened this issue Nov 5, 2024 · 0 comments
Open

Comments

@developerjet
Copy link

developerjet commented Nov 5, 2024

具体情况如下,bugly数据采集。麻烦您看下呢,多谢了。

使用JXSegmentedView的场景主要是实现短视频左右滑动Feed流,因为还要做请求数据加载更多,所以有给listContainerView的scrollView增加contentOffset的KVO监听,通过监听contentOffset值变化,来做加载更多处理。

    override func observeValue(forKeyPath keyPath: String?, of object: Any?, change: [NSKeyValueChangeKey : Any]?, context: UnsafeMutableRawPointer?) {
        if keyPath == "contentOffset" {
            if let newOffset = change?[.newKey] as? CGPoint {
                let contentWidth = listContainerView.scrollView.contentSize.width
                let width = listContainerView.scrollView.frame.width
                //debugPrint("newOffset===\(newOffset)")
                
                if newOffset.x <= 0 {
                    // 检查是否在最左边
                    handlerNewRefresh(with: newOffset.x)
                }
                else if newOffset.x >= contentWidth - width + loadMoreMaxXOffset {
                    // 检查是否在最右边
                    handlerMoreRefresh(with: newOffset.x)
                }
            }
        }
        else {
            super.observeValue(forKeyPath: keyPath, of: object, change: change, context: context)
        }
    }
    
    private func handlerNewRefresh(with contentOffsetX: CGFloat) {
        //print("handlerNewRefresh contentOffsetX====\(contentOffsetX)")
        
        if contentOffsetX <= loadNewMinXOffset && scrollIndex == 0 {
            if !isLoadingData && listContainerView.scrollView.isDragging == false {
                isLoadingData = true
                ToastTool.showLoading(inView: self.view)
                DispatchQueue.main.asyncAfter(deadline: .now() + 0.25) {
                    self.loadPagerNewData()
                }
            }
        }
    }
    
    private func handlerMoreRefresh(with contentOffsetX: CGFloat) {
        //print("handlerMoreRefresh contentOffsetX====\(contentOffsetX)")
        
        if scrollIndex > 0 && scrollIndex == viewControllersList.count - 1 {
            if !isLoadingData && listContainerView.scrollView.isDragging == false {
                isLoadingData = true
                ToastTool.showLoading(inView: self.view)
                DispatchQueue.main.asyncAfter(deadline: .now() + 0.35) {
                    self.loadPagerMoreData()
                }
            }
        }
    }

#1052 NSInternalInconsistencyException
<UICollectionViewLayoutAttributes: 0x131d2c5d0; index path: (0-1); frame = (149.5 0; 132.5 44)>: An -observeValueForKeyPath:ofObject:change:context: message was received but not handled. Key path: status Observed object: <AVPlayerItem: 0x3008937b0, asset = <AVURLAsset: 0x300a028a0, URL = http://localhost:52954/https%3A%2F%2Fd16n6tdp1xddz9%2Ecloudfront%2Enet%2Fshare%5Fmoment%2F2024%2F10%2F15%2F1728959521%5F2304x1296%5F%2D0cad5599a76f4dc78dfc3456cbd4ec91%2Emp4/KTVHTTPCachePlaceHolder/KTVHTTPCacheLastPathCompo

CoreFoundation ___exceptionPreprocess

image
image
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant