hmsegmentedcontrol - 当我滚动时,标签荧光笔总是变为 0。为什么?

hmsegmentedcontrol - When I scroll, the tab highlighter always changes to 0. why?

HMSegmentControl中,我在其中一个段视图中添加了表视图。当我在当前部分向上或向下滚动时,我注意到选项卡荧光笔总是变为 0。为什么会这样?

这是我的 scrollView 代码:

-(void)scrollViewDidScroll:(UIScrollView *)scrollView
{
    CGFloat pageWidth = scrollView.frame.size.width;
    int page = scrollView.contentOffset.x / pageWidth;
    [self.chatSegment setSelectedSegmentIndex:page animated:YES];
    NSLog(@"scrollViewDidScroll - You are now on page %i",page);
}

日志值:

<UITableView: 0x128007e00; frame = (0 0; 320 568); clipsToBounds = YES; tag = 502; gestureRecognizers = <NSArray: 0x1276c2690>; layer = <CALayer: 0x1276c20e0>; contentOffset: {0, 2}; contentSize: {320, 570}>

当table在垂直方向滚动时,偏移量y值会改变,x值永远为0。

所以在你的情况下,你应该参考scrollView.contentOffset.y