Domanda

I'm using this source code for adding a sliding menu similar to the Facebook App:

Git Hub Project ECSlidingViewController: https://github.com/edgecase/ECSlidingViewController

Here is the code for my Custom UINavigation Controller:

@implementation NavViewController

- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];

    if (![self.slidingViewController.underLeftViewController isKindOfClass:[ZAPMenuViewController class]])
    {
        self.slidingViewController.underLeftViewController  = [self.storyboard instantiateViewControllerWithIdentifier:@"Menu"];
    }

    [self.view addGestureRecognizer:self.slidingViewController.panGesture];
}

However, I have a UITableView and I need to be able to swipe to delete. Is there a way to disable the panGesture when swiping the the left, but leave the panGesture for swiping to the right and revealing the menu?

È stato utile?

Soluzione

Also check out some answers on ECSlidingViewController's wiki which include allowing simultaneous gestures to be recognized.

- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer
 *)otherGestureRecognizer {
     if ([otherGestureRecognizer.view isKindOfClass:[UIScrollView class]]) {
         return YES;
     } else {
         return NO;
     } }

Altri suggerimenti

As a workaround you can use UIView placed in the "background" of your controller and connect panGesture to it. So instead of

[self.view addGestureRecognizer:self.slidingViewController.panGesture];

I used UIView outlet

@property (strong, nonatomic) IBOutlet UIView *slideOutArea;

and then in proper method like viewWillAppear

[self.slideOutArea addGestureRecognizer:self.slidingViewController.panGesture];
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top