Dávid Kaszás
Dávid Kaszás

Reputation: 1977

iOS Multiple Navigation Controllers with swipe menu

I implemented a Facebook like swipe menu, but i have problems with the navigation.

I have 3 ViewControllers

Now i want to perform a segue from the HomeViewController to the Second page. I placed a button at the HomeViewController and cmd + dragged it to the second page, Action segue: Push.

When i run the application, i get the next error message:

Terminating app due to uncaught exception 'NSGenericException', reason:
'Push segues can only be used when the source controller is managed by
an instance of UINavigationController.'

So basically I want to create the exact same navigation what the facebook uses, menu button at the main page else back button at the top left corner.

Any idea would be appreciated!

StoryBoard

Facebook like swipe menu

Upvotes: 1

Views: 1207

Answers (1)

DBD
DBD

Reputation: 23223

You might want to consider a container view controller. Instead of having the menu leave the current view controller and go to a different one, have the menu come up as a child view controller in a pre-defined view on the original view controller.

This has some benefits like:

  1. Custom animations of the menu appearing/disappearing
  2. Partial screen menus which leave some of the original screen visible (makes users feel like it's a menu and they are still at the same place)

When the user triggers the menu (swipe/tap/etc) you would add the menu "child" view controller to the (offscreen) view, then animate the view to visible location (which could be as simple as changing the frame.origin.x). When dismissed just reverse the process.

Upvotes: 1

Related Questions