Open HyunjoonKo opened 4 years ago
I have got this error too
Thanks for your feedback!
May I ask what version of SegementSlide you used?
@Jiar I am currently using version 3.0.1. The problem has occurred since Xcode 12 (Swift 5.3).
@HyunjoonKo @lumanmann I run the Example under the same environment, but no problem is found. It is better to have a Demo that can reproduce the problem, otherwise it is difficult to troubleshoot the problem.
I have got the same error from Firebase Crashlytics report.
So as I... Is there anyone who solved this problem?
@hansolnoh95 Not yet. It does not appear in the development environment, but many reports are still reported in Crashlytics and Xcode crash reports.
@Jiar Update information:
internal func childScrollViewDidScroll(_ childScrollView: UIScrollView) {
defer {
scrollViewDidScroll(childScrollView, isParent: false)
}
let parentContentOffsetY = scrollView.contentOffset.y // 0.0
let childContentOffsetY = childScrollView.contentOffset.y // 0.0
switch innerBouncesType {
case .parent:
if !canChildViewScroll {
childScrollView.contentOffset.y = 0 // Thread 1: EXC_BAD_ACCESS (code=2, address=0x16b8e3ff0)
} else if childContentOffsetY <= 0 {
canChildViewScroll = false
canParentViewScroll = true
}
case .child:
if !canChildViewScroll {
childScrollView.contentOffset.y = 0
} else if childContentOffsetY <= 0 {
if parentContentOffsetY <= 0 {
canChildViewScroll = true
}
canParentViewScroll = true
} else {
if parentContentOffsetY > 0 && parentContentOffsetY < headerStickyHeight {
canChildViewScroll = false
}
}
}
}
The problem was solved when I tried to fix it as follows:
// ...
case .parent:
if !canChildViewScroll, childScrollView.contentOffset.y != childContentOffsetY {
childScrollView.contentOffset.y = 0
} else if childContentOffsetY <= 0 {
canChildViewScroll = false
canParentViewScroll = true
}
// ...
@Jiar Update information:
internal func childScrollViewDidScroll(_ childScrollView: UIScrollView) { defer { scrollViewDidScroll(childScrollView, isParent: false) } let parentContentOffsetY = scrollView.contentOffset.y // 0.0 let childContentOffsetY = childScrollView.contentOffset.y // 0.0 switch innerBouncesType { case .parent: if !canChildViewScroll { childScrollView.contentOffset.y = 0 // Thread 1: EXC_BAD_ACCESS (code=2, address=0x16b8e3ff0) } else if childContentOffsetY <= 0 { canChildViewScroll = false canParentViewScroll = true } case .child: if !canChildViewScroll { childScrollView.contentOffset.y = 0 } else if childContentOffsetY <= 0 { if parentContentOffsetY <= 0 { canChildViewScroll = true } canParentViewScroll = true } else { if parentContentOffsetY > 0 && parentContentOffsetY < headerStickyHeight { canChildViewScroll = false } } } }
The problem was solved when I tried to fix it as follows:
// ... case .parent: if !canChildViewScroll, childScrollView.contentOffset.y != childContentOffsetY { childScrollView.contentOffset.y = 0 } else if childContentOffsetY <= 0 { canChildViewScroll = false canParentViewScroll = true } // ...
how can you fix it, can you share the why?
Hi @skeyboy
You can see the fixed source code here: https://github.com/HyunjoonKo/SegementSlide/blob/customized/Source/General/SegementSlideViewController%2Bscroll.swift
Install with CocoaPods:
pod 'SegementSlide', :git => 'https://github.com/HyunjoonKo/SegementSlide.git', :branch => 'customized'
If childScrollView.contentOffset.y
is 0
, setting 0
again will cause a crash. I don't know why this happens. Because I don't know how to reproduce the phenomenon. I could only tell which code was the problem by looking at the crash report.
A lot of error reports came into my app's Crashlytics. Please check.
Stack trace:
in SegementSlideViewController+scroll.swift: