0

I try to use SWReveal to manage menu and views in an iOS app. No problem for implement it.

The 'sw_front' view controller is the home for the app. There's 4 buttons to access to 4 different screens. The 'sw_rear' view controller is the menu to access screens directly.

For others screens, I want a 'back button' to return to the home of the app 'sw_front'. When I acces screens from 'sw_front', everything works fine, I've got a 'back button'. But when I access screen from 'sw_rear', I can't have 'back button'. I also want when user tap on 'back button', he return automatically on 'sw_front' (app home) and not on 'sw_rear'.

Here is a screenshot SWReveal navigation between views

How can I achieve this ? I didn't find informations or examples.

So please, help me !

Thanks for your response !

kopacabana
  • 437
  • 3
  • 17

2 Answers2

0

You shouldn't have the back button, technically speaking. When you click a button in sw_rear, it is not pushing a view controller on top of the home view.

May be try adding a back button elsewhere, and try

[self dismissViewControllerAnimated:YES completion:nil];
  • Thanks for your response. I completely change the logic and it's work ! When I click on a menu item, I push a view in HomeViewController navigation. – kopacabana Jan 07 '16 at 12:00
  • @kopacabana Can you please create an answer with your solution? I mean, how to organize the viewControllers. – JCarlosR May 02 '17 at 14:25
  • Hi @JCarlos I try to give you more informations asap but I'm completely submerged. Please send me new message if you haven't informations about me. Thanks – kopacabana Oct 24 '17 at 16:50
0

I add a new ViewController between SWRevealViewController and NavigationViewController. This viewController is connect to SWRevealViewController as 'sw_rear'. I remove segue from my existing NavigationController.

In this new ViewController, I create my NavigationController with :

let storyboard = UIStoryboard(name: "Main", bundle: nil)
let navVC = storyboard.instantiateViewController(withIdentifier: "nav") as! UINavigationController
navVC.view.frame = CGRect(x: 0, y: 0, width: UIScreen.main.bounds.width, height: UIScreen.main.bounds.height)
self.view.addSubview(navVC.view)
self.addChildViewController(navVC)

Now I can add screens to my NavigationViewController

navVC.push(otherViewController)
kopacabana
  • 437
  • 3
  • 17