2

I'm developing an app for iOS with a menu like Facebook with ECSlidingViewController, a nice project to manage the horizontal gesture on the app. The problems borns when I put into the view an UISlider... I can't touch it nice because the sliding motion of the sliders is being mistaken as a swipe left/right. This is the header file of che class with all the methods and this is the code to put in the main view:

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

  if (![self.slidingViewController.underRightViewController isKindOfClass:[UnderRightViewController class]]) {
    self.slidingViewController.underRightViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"UnderRight"];
  }

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

This last line is the code that integrate the gesture on the app. Is there a method to disable the gesture only on the uislider?

Thanks at all.

Kerberos
  • 4,036
  • 3
  • 36
  • 55

1 Answers1

2

You can add a delegate to self.slidingViewController.panGesture and have it ignore touches that are on a UISlider view. The following question and answer have all the information you need: Pan gesture interferes with UISlider.

Community
  • 1
  • 1
Scott Robertson
  • 266
  • 3
  • 9
  • 1
    I just checked the ECSlidingViewController, and they aren't assigning a delegate for `panGesture`, so you can use the answer linked above without issue. If they change their code in the future to use a `UIGestureRecognizerDelegate` then your code will break. – Scott Robertson Jun 05 '12 at 23:55
  • I'm sorry but I have some difficulty with English and Obj-c :D I must create the delegate of ECSlidingViewController? And then, I must implement something like this: if ([self.slidingViewController.panGesture isKindOfClass:[UISlider class]]) { self.slidingViewController.panGesture.enabled=NO; } ? – Kerberos Jun 09 '12 at 08:49
  • 1
    So your main view controller needs to be a `UIGestureRecognizerDelegate`, and then you need to add a method to the class called `- (void)gestureRecognizer:(UIGestureRecognizer*)gestureRecognizer shouldRecieveTouch:(UITouch*)touch`. The code for this method is in the linked question. After adding the gesture recognizer to your main view, add the following line: `self.slidingViewController.panGesture.delegate = self;` – Scott Robertson Jun 12 '12 at 19:58