FSPagerView icon indicating copy to clipboard operation
FSPagerView copied to clipboard

crash 'attempt to scroll to invalid index path'

Open sashakid opened this issue 4 years ago • 1 comments

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.

sashakid avatar Sep 08 '19 10:09 sashakid

I have the same problem. I can try this pagerView.scrollToItem(at: index, animated: true)

ls19491314 avatar Sep 21 '19 07:09 ls19491314