I am using a scrollView with two containers in order to add a slide out menu to a tabbed app that I am working on.
When the app is launched, if the user is already logged in, the main page is presented and the left slide menu is initially closed. However, if the user is not logged in and has to get to the main page via the login button, the main page is presented with the menu open. I cannot figure out how to present it closed.
In the mainViewController this is the func used to close the menu initially
func closeMenu(animated:Bool = true){
scrollView.setContentOffset(CGPoint(x: leftMenuWidth, y: 0), animated: animated)
}
In the viewDidLoad I call the following to initially close the menu
dispatch_async(dispatch_get_main_queue()) {
self.closeMenu(true)
}
I am using NSNotifications to toggle the menu open and closed via a button on the main page. So I tried to post the 'toggleMenu' notification when the login button is tapped but that does not work
PFUser.logInWithUsernameInBackground(username!, password: password!) {
(user: PFUser?, error: NSError?) -> Void in
if user != nil {
print("successful login")
dispatch_async(dispatch_get_main_queue(), { () -> Void in
let viewController:UIViewController = UIStoryboard(name: "Main", bundle: nil).instantiateViewControllerWithIdentifier("ContainerHome")
self.presentViewController(viewController, animated: true, completion: nil)
NSNotificationCenter.defaultCenter().postNotificationName("toggleMenu", object: nil)
})
}
I am a beginner, so if i left out some details I do apologize.
Thanks in advance for any help given.