I thought I was cursed by the ghost of Jobs because I tried all possible solutions from all the related questions here on StackOverflow and I could not get my scrollviews to work together.
If none of the above answers work for you - make sure you don't have a subclass of UIScrollView or a subclass inside your table cells. Scrolling through your view of subviews and disabling scrollsToTop do nothing if your tableView has not yet loaded it as subviews.
The solution that worked for me was to create a public method disableScrollsToTop in my subclass of UITableViewCell that sets the scrollsToTop property of its scroll view NO .
The code I use (with generic names):
MYViewController.m
- (void)viewDidLoad { // ... your initialization code [self setupScrollViewScrolling]; } - (void)setupScrollViewScrolling { self.horizontalScrollView.scrollsToTop = NO; self.tableView.scrollsToTop = YES; } // Note that I am using Xibs here, and your implementation for storyboards/xibless will be slightly different. - (UITableViewCell *)tableView:(UITableView *)aTableView cellForRowAtIndexPath: MyTableViewCell *cell; static NSString *identifier = @"IdentifierForCell"; if (!(cell = [self.tableView dequeueReusableCellWithIdentifier:identifier])) { [[NSBundle mainBundle] loadNibNamed:@"MYTableViewCell" owner:self options:nil]; cell = self.tableViewCell; self.tableViewCell = nil; // ... cell initialization code [cell disableScrollsToTop]; } return cell; }
And of course, disableScrollsToTop just
MYTableViewCell.m
- (void)disableScrollsToTop { self.subviewThatScrolls.scrollsToTop = NO; }
Another way (perhaps more extensible) can be done is the wrapping UITableView reloadData , and after the reboot, a recursive scrolling method is called, for example, that @Dominic_Sander says, although I did not check this solution, since I did messing with this problem.
source share