FSPagerView
FSPagerView copied to clipboard
crash 'attempt to scroll to invalid index path'
I have a strange crash 'attempt to scroll to invalid index path: <NSIndexPath: 0x280a6dda0> {length = 2, path = 18446744073709551615 - 23}' and have noticed that it's connected with this function:
fileprivate func nearbyIndexPath(for index: Int) -> IndexPath {
// Is there a better algorithm?
let currentIndex = self.currentIndex
let currentSection = self.centermostIndexPath.section
if abs(currentIndex-index) <= self.numberOfItems/2 {
return IndexPath(item: index, section: currentSection)
} else if (index-currentIndex >= 0) {
return IndexPath(item: index, section: currentSection-1)
} else {
return IndexPath(item: index, section: currentSection+1)
}
}
What is the purpose of it? I have one section with index 0 and I don't need such calculations :-) because when I get here return IndexPath(item: index, section: currentSection-1)
, I have crash.
I have the same problem. I can try this
pagerView.scrollToItem(at: index, animated: true)