简体   繁体   中英

Facebook Chat (iOS) - swipe to Left

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM