lugonja
lugonja

Reputation: 313

disable scrolling of table view when scroll view in table view is selected

I have custom cell in table view that contains label, image view and scroll view. Scroll view can be scrolled only horizontally(bounds for vertical size of scroll view is cell height) but I want to forbid table view to scroll down/up when I am moving scroll view. When i drag image view or label I want my table view to scroll.

Upvotes: 1

Views: 1161

Answers (1)

Mathijs
Mathijs

Reputation: 1268

Untested:

- (void)scrollViewDidScroll:(UIScrollView *)scrollView{
    if (scrollView == <point to horizontal scrollView here>)
    {
        tableView.scrollEnabled = NO;
        tableView.alwaysBounceVertical = YES;
    }
}

- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView {
    if (scrollView == <point to horizontal scrollView here>)
    {
        tableView.scrollEnabled = YES;
        tableView.alwaysBounceVertical = YES;
    }
}

Don't forget to set

scrollView.delegate = self;

and add UIScrollViewDelegate in the header file.

Upvotes: 1

Related Questions