質問

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

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top