0

I have a UIScrollView with a UIView subview, which has a UITableView subview. What I want is for the container scroll view to scroll when the user scrolls on the UITableView. Is there a way to pass the touch event from the child UIScrollView to the container UIScrollView? Thanks for you help. Here is the code for the scroll view. The parent scroll view is created in code, and the subviews are created in IB.

CGFloat offset = ([[UIDevice currentDevice].systemVersion floatValue] >= 7.0) ? 64.0 : 44.0;
self.parentScrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0.0, offset, 320.0, self.view.frame.size.height - offset)];
self.parentScrollView.delegate = self;
self.parentScrollView.bounces = NO;
self.parentScrollView.contentInset = UIEdgeInsetsMake(self.header.frame.size.height - offset, 0, 0, 0);
self.parentScrollView.delaysContentTouches = NO;
[self.view addSubview:self.parentScrollView];

[self.contentView.tableView registerNib:[UINib nibWithNibName:@"PodcastCell" bundle:[NSBundle mainBundle]] forCellReuseIdentifier:@"PodcastCell"];
[self.contentView.tableView registerNib:[UINib nibWithNibName:@"DescriptionCell" bundle:[NSBundle mainBundle]] forCellReuseIdentifier:@"DescriptionCell"];
self.contentView.delegate = self;
self.contentView.tableView.delegate = self;
self.contentView.tableView.dataSource = self;
[self.parentScrollView addSubview:self.contentView];
self.parentScrollView.contentSize = CGSizeMake(320.0, self.contentView.frame.size.height);

Sorry I didn't explain this very well. I need the parent UIScrollView to scroll until the child UITableView reaches the top of the parent, at which point the parent UIScrollView should stop scrolling, and the child UItableView should start scrolling. Does that make sense?

Chandler De Angelis
  • 2,646
  • 6
  • 32
  • 45

1 Answers1

0

Implement scrollViewDidScroll: in your UITableView, calculate the contentOffset then call setContentOffset:animated: from your container view.

Infinity
  • 3,695
  • 2
  • 27
  • 35