简体   繁体   English

UIScrollView中的UITableView,滚动不起作用

[英]UITableView inside UIScrollView, scroll not working

I'm trying to implement the following hierarchy 我正在尝试实现以下层次结构

-- UISCrollView
  -- ContainerView
    -- UITableView

初期

Initially the UITableView scroll is disabled. 最初, UITableView scroll被禁用。 When the UICollectionView reaches a particular contentOffset of the UIScrollView , I implement this : UICollectionView到达UIScrollView的特定contentOffset时,我实现了这一点:

- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{

    if (scrollView.contentOffset.y >= 140)
    {
        [scrollView setContentOffset:CGPointMake(0, 140) animated:NO];
    }
}

滚动后

All this works as intended, but now the UIScrollView is eating the scroll of the UITableView . 所有这一切都按预期工作,但是现在UIScrollView正在吃UITableView的滚动。 The scroll of UITableView is erratic now and doesn't scroll properly. UITableView滚动现在不稳定,并且无法正确滚动。 The scroll of UITableView happens only after 7-8 attempts and then it stops again. UITableView的滚动仅在尝试7-8次后发生,然后再次停止。

What might be the reason of this behaviour? 这种行为的原因可能是什么? I tried setting myScrollView.scrollEnabled = NO inside scrollViewDidScroll and no luck. 我试过在scrollViewDidScroll内设置myScrollView.scrollEnabled = NO ,也没有运气。

您可以延迟主滚动视图的触摸响应,然后可以正确滚动子表视图(scrollview):

myScrollView.panGestureRecognizer.delaysTouchesBegan = YES;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM