I'm developing a application using ECSliding framework. Everything was going well until I add a UItableViewController as the topViewController. I'm facing an error while trying to scroll the static table view. I could identify where is the problem but I don't know how to solve it. If I delete the command bellow (declared at viewDidLoad method), my UITableView starts to scroll normally.
[self.view addGestureRecognizer:self.slidingViewController.panGesture];
Code used to set the UITableViewController as the topViewController
self.topViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"Driver"];
topViewController is a property from the ECSlidingViewController
I have found another similar question on another post, but there, the guy was using a UINavigationController as the topViewController.
Please let me know if someone can give me a hand.
thanks, Marcos.
I see that you solved your issue but per-comments other people are looking for this solution as well, so I will give some information about this.
The problem here is that when you add a pan gesture to the UITableView subclass it messes with the current gestures used for scrolling. When you pan it no longer knows what you are after and you can end up with inconsistent behavior (or behavior you did not want).
There are a couple of different solutions that may work pending on your actual needs:
ONE:
If you become UIGestureRecognizerDelegate you can implement the method:
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer
{
return TRUE;
}
This allows you to listen for multiple gestures. Just make sure you set your gesture's delegate to self
TWO:
If you specify what direction you want the new gesture to implement you may cease having scrolling problems:
UISwipeGestureRecognizer* swipe;
swipe = [[[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(handleSwipeL)] autorelease];
swipe.direction = UISwipeGestureRecognizerDirectionLeft;
[view addGestureRecognizer:swipe];
swipe = [[[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(handleSwipeR)] autorelease];
swipe.direction = UISwipeGestureRecognizerDirectionRight; // default
[view addGestureRecognizer:swipe];
Obviously this is using a swipe, but it could easily be modified. This says that you do not want to worry about vertical gestures and you can allow the table to continue its default behavior. You may still need to implement the delegate method in ONE though, to verify that it listens for multiple gestures.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With