UITableView scrolling issues when inside a UIScrollView

I have a UIScrollView (with paging) to which I add three UIViews. Each of these UIViews has a UITableView inside. Thus, the user should be able to scroll horizontally to the page that he wants, and then scroll vertically in the corresponding table.

However, some of the tables do not receive scroll gestures. Usually the first behaves well, while the others do not. I cannot select cells or scroll the table up or down.

I used the default settings for UIScrollView, with the exception of those defined in viewDidLoad:

- (void)viewDidLoad { [super viewDidLoad]; //Load the view controllers [self loadViewControllers]; //Configure the scroll view self.scrollView.pagingEnabled = YES; self.scrollView.contentSize = CGSizeMake(CGRectGetWidth(self.scrollView.frame) * viewControllers.count, CGRectGetHeight(self.scrollView.frame)); self.scrollView.showsHorizontalScrollIndicator = NO; self.scrollView.showsVerticalScrollIndicator = NO; self.scrollView.scrollsToTop = NO; self.scrollView.delegate = self; //Configure the page control self.pageControl.numberOfPages = viewControllers.count; self.pageControl.currentPage = 0; } 

I can’t understand why I can’t scroll through some tables ... Any help would be greatly appreciated.

Thanks in advance!

+8
ios iphone uitableview scroll uiscrollview
source share
4 answers

Things I would check:

  • Check your view hierarchies. Is something stacked on top of your UITableView so that it doesn't receive a response?
  • Are your UITableViews disabled anywhere? I would set a breakpoint in tableView:didSelectRowAtIndexPath: and see if this method would be called.
  • Mark this post

I think these are not reliable answers, but hopefully they will help find the problem!

+2
source share

Try to install

 self.scrollView.delaysContentTouches = YES; self.scrollView.canCancelContentTouches = NO; 

Perhaps UIScrollView does not pass sensory data to subheadings.

+4
source share

I tried to reproduce a simplified version of your needs, using mostly Interface Builder, and it seems to me that it works using basic coding and uses the default settings. Can you check out my quick n dirty Github report and ask for an answer if it applies to your situation or absence.

https://github.com/codedad/SO_ScrollView_with_Tables

By default, Interface Builder creates UIScrollView and UITableViews that allow:

  • Content Delay Disabled
  • Undoable content is disabled
+4
source share

It worked for me

I programmatically added a tableView to my scroll using addSubview:

UIGestureRecognizerDelegate .

 - (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch { if ([touch.view isDescendantOfView:self.signUpJammerList]) { return NO; } return YES; } 
0
source share

All Articles