简体   繁体   中英

Add Gesture recognizer

I have two viewController : FirstViewController and SecondViewController

I make an animation that make a view come from right to left.

I want when a make a sweep to right the SecondViewController hide and show the FirstViewController

the animation work there is the code

SecondViewController *secondViewController = [[SecondViewController alloc]      initWithNibName:@"PlayListController" bundle:nil];
// Set up view2
secondViewController.view.frame = self.view.frame;
secondViewController.view.center = CGPointMake(self.view.center.x +   CGRectGetWidth(self.view.frame), self.view.center.y);
[self.view.superview addSubview:secondViewController.view];
// Animate the push
[UIView beginAnimations: nil context: NULL];
[UIView setAnimationDelegate: self];
[UIView setAnimationDidStopSelector: @selector(pushAnimationDidStop:finished:context:)];
secondViewController.view.center = self.view.center;
self.view.center = CGPointMake(self.view.center.x - CGRectGetWidth(self.view.frame), self.view.center.y);
[UIView commitAnimations];

I added a buttons to hide the view with an animation but it doesn't work ??

  1. Add a gesture recogniser to your view.
  2. In the callback, pop the view controller.

Caveat: this is non standard UI. Better go with a standard navigation bar and a back button.

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