aryaxt / iOS-Slide-Menu

iOS Slide Menu with ability to add both left and right menu, and built in gesture recognizer. Similar to Path and Facebook
Other
1.53k stars 359 forks source link

Can't create SlideNavigationController #198

Closed caraldel closed 8 years ago

caraldel commented 8 years ago

I'm trying to create a left slide menu with your approach. My entry point in the StoryBoard isn't the SlideNavigationController and when I load the view with is root view of the SlideNavigationController, there is a message in the console: "SlideNavigationController has not been initialized. Either place one in your storyboard or initialize one in code" and the left bar button doesn't appear and when I slide the view, the left menu is 'black'. Do you know why ?

Thanks.

SCLDev commented 8 years ago

I had the same problem, and I found it was because the navigation controller wasn't the starting point. I had a login view, that was not supposed to be passed through without authentication.

This is what I did to get around the issue:

  1. start with the navigation controller as the entry point.
  2. set the navigation buttons to no (both right and left methods, check the documentation for the two delegate methods).
  3. I didn't want to show the navigation controller bar either, so I set the bar to be hidden when the login view was loaded (viewDidAppear or viewWillAppear).
  4. unhide the bar when leaving the view (viewDidDisappear / viewWillDisappear)
  5. use the popAllToRootViewController.... method of the SlideNavigationController to navigate to the new view (the one that you want to show the buttons on), set the menu buttons using the two method (check documentation).
  6. It's pretty much done. One thing, if you want to go back to the view that didn't have the buttons, just use the same popToRootViewController.... method. I even used a flag to make sure that the view won't show the menu.

I know my method may not be the best solution for you, but it works, and works really well.

Let me know if you found any more on that.

Sep

mattiaskronberg commented 8 years ago

Hi, @SCLDev , just wanted to thank you for your solution. I was stuck for hours...

SCLDev commented 8 years ago

@mattiaskronberg I'm glad you could use it.

onderozcan commented 8 years ago

I am really stuck that library too. No actual documentation in github page. Demo application also confusing and i got same error "SlideNavigationController has not been initialized. Either place one in your storyboard or initialize one in code" even my first stack starting with Navigation Controller.

aryaxt commented 8 years ago

@onderozcan the recommended use of SlideNavigationController is to be set as the rootViewController (as the demo does), you are seeing this error if you try to access the singleton instance before initializing the slideNavigationController.

You still have the option of not setting it as root, but then you are responsible to make sure that you are trying to access it after it gets initialized.

https://github.com/aryaxt/iOS-Slide-Menu/blob/master/SlideMenu/Source/SlideNavigationController.m#L70

The reason for a bit unusual use of singleton pattern is to support initializing the slideMenu through storyboard.