0

I want to implement slide down interaction and dismiss view controller, for which i referred this link , but this works only for dismissing a single view controller presented from view controller.

In my case, i have presented a navigation controller as user can push to another view from that view controller, but drag down to dismiss doesn't work with navigation controller.

UPDATED:It should work as - slide down gesture is triggered from any of the screens, (for eg: from main screen or pushed screen/detail screen) the navigation controller should dismiss completely.

Please suggest if anyone has come across implementing the same.

Thanks in advance.

Community
  • 1
  • 1
khushboo
  • 260
  • 2
  • 12
  • You need to show what you are doing in order for someone to figure out what's missing. Please share your code – Malik May 03 '17 at 07:10
  • I have used the same code from the link which i have linked in the question,created ViewControllerPannable class, and used it, but it doesnt seems to work. – khushboo May 03 '17 at 08:56
  • One thing to keep in mind is that a modal controller and a navigation controller have different ways of `dismissing` a controller. For a modal controller, you would use `dismissViewController` whereas in a navigation controller, you would use `navigationController.popViewController` (because it is pushed onto a navigation stack) – Malik May 03 '17 at 09:01
  • i have to implement as - on swipe down or panning down the view controller it should dismiss whole navigation controller. – khushboo May 03 '17 at 09:12

1 Answers1

-1

You can add PanGesture in your navigation controller. Using - (CGPoint)velocityInView:(UIView *)view you will know in which direct user panned. if view was panned down manage its constraint accordingly and if it is more than a threshold value pop that view.

Priyal
  • 879
  • 1
  • 9
  • 30
  • @Malik but it works with modal presentation. Which is the problem. It is not too complex to implement so just gave an option to implement according to the requirement. – Priyal May 03 '17 at 07:16
  • A gesture recogniser is not bound by the presentation style of a view controller. Using a navigation controller in lieu of a modal controller does not render a gesture recogniser useless. – Malik May 03 '17 at 07:18