pujiaxin33 / JXCategoryView

A powerful and easy to use category view (segmentedcontrol, segmentview, pagingview, pagerview, pagecontrol) (腾讯新闻、今日头条、QQ音乐、网易云音乐、京东、爱奇艺、腾讯视频、淘宝、天猫、简书、微博等所有主流APP分类切换滚动视图)
MIT License
6.08k stars 1.15k forks source link

点击JXCategoryTitleView的item选项时,不走listContainerView:initListForIndex:代理方法 #479

Closed 13923927013 closed 9 months ago

13923927013 commented 1 year ago

JXCategoryTitleView有两个titleItem,进入页面时默认选中第一个item,对应第一个列表会加载。但是,当点击第二个titleItem时,却不会走listContainerView:initListForIndex:代理方法,而通过滑动到第二个titleItem时却会走这个代理方法。

经排查问题如下图: image

ExchangeMe commented 1 year ago

+1 我也遇到了 :- (id)pagerView:(JXPagerView *)pagerView initListAtIndex:(NSInteger)index 点击不走 滑动走
注销你提供的上面代码还是不走 必须滑动才走

我的解决方案:

- (void)categoryView:(JXCategoryBaseView *)categoryView didSelectedItemAtIndex:(NSInteger)index {
    [self.pagerView.listContainerView setDefaultSelectedIndex:index];
    [self.pagerView.listContainerView reloadData];
}
pujiaxin33 commented 9 months ago

通过点击title的时候,是通过下面的方法来处理事件的

- (void)clickSelectItemAtIndex:(NSInteger)index {
    if (self.delegateFlags.canClickItemAtIndexFlag && ![self.delegate categoryView:self canClickItemAtIndex:index]) {
        return;
    }

    [self selectCellAtIndex:index selectedType:JXCategoryCellSelectedTypeClick];
}

所以,你截图里面的方法是要走return逻辑的。