Closed Gaozn closed 3 months ago
我尝试添加了这个方法来实现,不知道会不会有什么影响? public func didClickSelectedItem(at index: Int, without:Bool=true) { if without{ if self.type == .collectionView{ self.collectionView.scrollToItem(at: IndexPath(item: index, section: 0), at: .centeredVertically, animated: true) }else{ let sx = scrollView.bounds.size.width*CGFloat(index) scrollView.setContentOffset(CGPoint(x:sx, y: 0), animated: true) } } self.didClickSelectedItem(at: index) }
the same issue
同样的问题,这个需求很大啊!
这样子 直接拿到contentScrollView 然后调用setContentOffset方法就行了 我这里用的是JXPagerListRefreshView JXPagingListContainerView应该也是一样的
- (void)switchSubPage:(NSInteger)index {
UIScrollView *contentScrollView = self.pagerView.listContainerView.contentScrollView;
CGPoint offset = CGPointMake(index*contentScrollView.bounds.size.width, 0);
[contentScrollView setContentOffset:offset animated:true];
[self.pagerView.listContainerView didClickSelectedItemAtIndex:index];
}
可以通过segmentedView的func selectItemAt(index: Int)
方法,实现选中某个index。OC版本就是categoryView的- (void)selectItemAtIndex:(NSInteger)index;
方法
我只使用了JXPagingListContainerView这个类。 我找到didClickSelectedItem这个方法,断点都会走,但是页面没任何反应 public func didClickSelectedItem(at index: Int) { guard checkIndexValid(index) else { return } willAppearIndex = -1 willDisappearIndex = -1 if currentIndex != index { listWillDisappear(at: currentIndex) listWillAppear(at: index) listDidDisappear(at: currentIndex) listDidAppear(at: index) } }