Question

Does the Facebook mobile app use UISwipeGestureRecognizers for Chat?

And if so, since it seems the "swipe to left to bring out the chat list controller" is valid on every view controller, does it mean the same UISwipeGestureRecognizer is coded into every Controller? Or is there an easier way to do this without having to deal with this code repetition?

UPDATE

Think I got it working with rounak's answer, but to confirm - is this the right way to be doing it: since I have 3 Nav Controllers, with each one pointing to a View Controller, I should

(1) add the gestureRecognizer to my viewdidLoad in each of my View Controller's immediately connected to my Nav Controlllers

  UISwipeGestureRecognizer *swipeGesture = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(handleSwipeGesture:)];
  swipeGesture.direction = UISwipeGestureRecognizerDirectionUp|UISwipeGestureRecognizerDirectionLeft;
  [self.navigationController.view addGestureRecognizer:swipeGesture];

(2) setup the action

-(void)handleSwipeGesture:(UISwipeGestureRecognizer *)sender {
  [self performSegueWithIdentifier:@"newSegue" sender:nil];
}

(3) Tie a segue from each of my View Controller's to the View Controller I want to show via Storyboard (ctrl + click), and name it appropriately

Was it helpful?

Solution

I'm guessing, yes they might be using gesture recognizers.

If you have multiple viewcontrollers inside a UINavigationController, you can simply add the gesture recognizer to navigationController.view

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top