Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SlideMenuController not a RootViewController #44

Open
lazarte opened this issue Jun 16, 2015 · 10 comments
Open

SlideMenuController not a RootViewController #44

lazarte opened this issue Jun 16, 2015 · 10 comments

Comments

@lazarte
Copy link

lazarte commented Jun 16, 2015

Hi Good Day,

How to use this library to be able to show it on the existing navigationcontroller?

Lets say we have a logincontroller on the navigationcontroller. After login I want to show this SlideMenuController which uses only the right. Can you give me sample code?

Thanks in advance!

@thihaaung6245
Copy link

Try to add this code in your view controller's viewDidLoad() which will be display after login successful

self.slideMenuController()?.openRight()

@lazarte
Copy link
Author

lazarte commented Jun 17, 2015

This is the flow.

  • NavigationController
    • LoginController
      • SlideMenuController

@thihaaung6245
Copy link

Would u mind sharing your sample project on dropbox or some cloud storage and see if i can fix

@lazarte
Copy link
Author

lazarte commented Jun 17, 2015

same with this one

#45

@lrojas94
Copy link

My app uses the same structure (kind of) What I did was add a navigationController as the mainViewController of the SlideMenuController. Having that done, you can choose to put buttons, open the LeftViewController or whatever you want, and also change viewControllers using the navigationController's presentViewController. That work's for me so far. The project's at work (which I will attend to on Monday), if you need to, I can show you a bit of code. Sorry, dont have a mac at home.

@alecsechechel
Copy link

Hi maybe this help

// MARK: - UICollectionViewDelegate
func collectionView(collectionView: UICollectionView, didSelectItemAtIndexPath indexPath: NSIndexPath) {
    dataKedzoh?.setSubdomain(companies[indexPath.row].subdomain)
    dataKedzoh?.getUserInfo()
    let vc = createMenuView()
    self.presentViewController(vc, animated: true, completion: nil)
}

// MARK: - Create menu
func createMenuView() -> SlideMenuController {

    let mainViewController = kStoryboard.instantiateViewControllerWithIdentifier("TakeLesson") as! TakeLessonViewController
    let leftViewController = kStoryboard.instantiateViewControllerWithIdentifier("LeftViewController") as! LeftViewController
    let nvc: UINavigationController = UINavigationController(rootViewController: mainViewController)

    leftViewController.mainViewController = nvc
    let slideMenuController = SlideMenuController(mainViewController:nvc, leftMenuViewController: leftViewController)

    return slideMenuController
}

and next screen
// MARK: - View Controller Cycle
override func viewDidLoad() {
super.viewDidLoad()
self.setNavigationBarItem()
}

@ded
Copy link

ded commented Aug 7, 2015

when setting leftViewController.mainViewController = nvc I get mainViewController is not a property of leftViewController

@ded
Copy link

ded commented Aug 7, 2015

btw, I was able to remove that one line altogether and it worked fine.

@yusufonderd
Copy link

I have same issue. Can you find any solution ? @lazarte

@Neeraj204
Copy link

Neeraj204 commented Jul 13, 2017

@ded @yusufonderd try this code:

    @IBAction func onBtnLoginClick(_ sender: Any) {

    let mainViewController = self.storyboard?.instantiateViewController(withIdentifier: "HomeViewController") as! HomeViewController
    let leftViewController = self.storyboard?.instantiateViewController(withIdentifier: "MenuViewController") as! MenuViewController
    let nvc: UINavigationController = UINavigationController(rootViewController: mainViewController)
    
    leftViewController.homeViewController = nvc
    let slideMenuController = SlideMenuController(mainViewController:nvc, leftMenuViewController: leftViewController)
    slideMenuController.automaticallyAdjustsScrollViewInsets = true
    slideMenuController.delegate = self
    self.navigationController?.pushViewController(slideMenuController, animated: true)

      }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants