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

KVO 监听崩溃 #85

Closed
wangjinshan opened this issue May 15, 2020 · 1 comment
Closed

KVO 监听崩溃 #85

wangjinshan opened this issue May 15, 2020 · 1 comment
Labels
question Further information is requested

Comments

@wangjinshan
Copy link

        if contentScrollView?.isTracking == true || contentScrollView?.isDecelerating == true {
            //用户滚动引起的contentOffset变化,才处理。
            var progress = contentOffset.x/contentScrollView!.bounds.size.width
            if Int(progress) > itemDataSource.count - 1 || progress < 0 {
                //超过了边界,不需要处理
                return
            }

这个地方有时候会崩溃 contentScrollView!.bounds.size.width 可能 == 0

@pujiaxin33
Copy link
Owner

你用新版本试一下呢?
这个之前就兼容处理过了:

                 if contentScrollView?.bounds.size.width == 0 {
                    // 如果contentScrollView Frame为零,直接忽略
                    return
                }
                var progress = contentOffset.x/contentScrollView!.bounds.size.width
                if Int(progress) > itemDataSource.count - 1 || progress < 0 {
                    //超过了边界,不需要处理
                    return
                }

@pujiaxin33 pujiaxin33 added the question Further information is requested label May 15, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants