Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add multiple UITableviewController inside a scroll view?

I want to make a profile viewcontroller something similar to Twitter. I believe it contains 3 different child UITableviewController which keeps switching by segmented control. But when I scroll my tableview of child viewController it scrolls the parent scroll view as well.

Can anybody explain how to achieve that behavior?

like image 656
kidsid49 Avatar asked Nov 09 '15 07:11

kidsid49


1 Answers

I know your problem exactly. Problem is, Twitter is not an example, Snapchat however is....

You have a root View Controller that embeds a UIScrollView (Subclassed). Inside this subclass, you want to override the gesture recognizers like so...

 -(BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer {
if (gestureRecognizer.state != 0 && otherGestureRecognizer.state != 1)
{
    return YES;
} else {
    return NO;
}

}

Now you should be able to swipe tableViewCells and not drag in all 4 directions at once.

like image 56
benjaminhallock Avatar answered Oct 18 '22 19:10

benjaminhallock