Sidemenu: Problem about push viewController from root viewcontroller of sideMunu

Created on 4 Jan 2017  ·  17Comments  ·  Source: jonkykong/SideMenu

In Objective-C, when i push viewController with code [self.navigationController pushViewController:viewController animated:YES], Xcode appears warning:SideMenu Warning: attempt to push a View Controller from Optional() where its navigationController == nil. It must be embedded in a Navigation Controller for this to work.
How to push view controller in Objective-C?

Most helpful comment

clearly the warning message is not self-explanatory if someone feels the need to ask for an explanation

All 17 comments

The warning message is self-explanatory.

clearly the warning message is not self-explanatory if someone feels the need to ask for an explanation

@agates4 @ricpi I'm open to suggestions.

@ricpi run pod update to get version 2.1.4 which has better dummy-proofed the problem you've encountered here.

Yeah, I'm getting the same issue as well, any help would be appreciated. Not dummy-proofed enough for me :), I don't understand problem from the error message.

Put your view controller in a navigation controller.

I have my sidemenu in a navigation controller already. The trouble comes when I try to push into a "submenu" view controller when I click on one of the Sidemenu items. Is there a good way to do this?
(so it goes Home --> LeftSideMenuNav --> SidemenuVC -?-> SubmenuVC)

No. Put your main view controller in a navigation controller.

Ah, Ok, will do so now.

Ok, so this got rid of the error, but it doesn't do what I want it to. I'll try to explain it a bit better, I think I was not clear enough before, apologies.

Basically I want the SideMenu to show up like below (it does, works great):

mainsidemenu

However when someone clicks on an item (such as "Forum"), I want a "subMenu" to show up looking like so:
subsidemenu 2ndlayer

After you click on a submenu item it will transfer to the destination VC, like the above solution did.

current Storyboard looks like this:
screen shot 2017-05-30 at 12 45 14 pm

you aren't doing it right

@agates4, That seems to be the case, are you able to point me in the right direction?

@itali43 I am asked these kinds of questions very often. Plain and simple: I don't have the time to help everyone. You need to read the README carefully as I've put a lot of time into making sure that it addresses these issues.

Thank you @jonkykong, while a bit cryptic, I found what you are referring to.

If anyone comes across the same issue as me, CTRL + F on the readme and type in "submenu". If you put that in your Navigation VC it should work make your submenu appear upon clicking and you won't get the error I was running into.

Thanks again for your time @jonkykong, and a great library.

Hi Guys, I have question. I've tried to set .subMenu as .menuPushStyle but I've stuck into another problem. Submenu works as a charm, but now I have a problem pushing the view controller into main stack. I've tried
navigationController?.pushViewController(detailsViewController, animated: true);
and
SideMenuManager.menuLeftNavigationController?.pushViewController(detailsViewController, animated: true)
Also tried via presentingViewController but I've got the same .subMenu navigation or missing behavior (nothing happens basically). Am I doing something wrong ?

@serhiisol calling push on presentingViewController should do the trick as long as presentingViewController is a navigation controller. Other than that, you can change the menuPushStyle right before you do the push.

ah, my apologies, I've used wrong controller, basically I've used

presentingViewController.navigationController?.pushViewController(teamInfoViewController, animated: true)

instead of

presentingViewController.pushViewController(teamInfoViewController, animated: true)
Was this page helpful?
0 / 5 - 0 ratings