JXSegmentedView icon indicating copy to clipboard operation
JXSegmentedView copied to clipboard

KVO 监听崩溃

Open wangjinshan opened this issue 4 years ago • 1 comments

        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

wangjinshan avatar May 15 '20 08:05 wangjinshan

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

                 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 avatar May 15 '20 08:05 pujiaxin33