Views Navigation Using Swipe Gesture

后端 未结 5 454
南旧
南旧 2020-12-07 13:47

How can I switch views vertically using swipe gestures ?

5条回答
  •  情话喂你
    2020-12-07 14:17

    I found my answer. I am posting the code for your reference. Thanks :-)

    in viewDidLoad

      UISwipeGestureRecognizer *swipeGesture = [[[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(swipedScreendown:)] autorelease];
      swipeGesture.numberOfTouchesRequired = 1;
      swipeGesture.direction = UISwipeGestureRecognizerDirectionDown;
      [m_pImageView addGestureRecognizer:swipeGesture];
    

    Now

    - (void)swipedScreendown:(UISwipeGestureRecognizer*) swipeGesture {
      m_pViewController = [[ViewController alloc] initWithNibName:@"ViewController" bundle:nil];
      CATransition *transition = [CATransition animation];
      transition.duration = 0.75;
      transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
      transition.type = kCATransitionPush;
      transition.subtype = kCATransitionFromBottom;
      transition.delegate = self;
      [self.view.layer addAnimation:transition forKey:nil];
      [self.view addSubview:PadViewController.view];
    }
    

    If you need some more clarification please post here.

提交回复
热议问题