I\'ve just started learning IOS development, I\'ve successfully implemented the SWRevealViewController by following a given tutorial online all is working as expected.
I
The Storyboard arrangement looks good. I have used SWRevealController
like below:
After you login (performing login service or some login process) write below code.
This code will change current rootViewController (In your case it is LoginViewController
) to SWRevealController
. So that it will work. And when ever you do logout change rootViewController to LoginViewController
.
SWRevealViewController *controller = (SWRevealViewController *)[self.mainStoryboard instantiateViewControllerWithIdentifier:@"RevealViewController"];
[self.window setRootViewController:controller];
Do not forget to assign StoryboardID = "RevealViewController" in Storyboard for SWRevealViewController
.
Swift Code:
Add below function to your AppDelegate.swift
file:
func changeRootViewControllerToSWRevealViewController () {
let storyboard = UIStoryboard(name: "Main", bundle: nil)
let controller = storyboard.instantiateViewControllerWithIdentifier("RevealViewController")
if let window = self.window{
window.rootViewController = controller
}
}
// Call above function in your login button action method like below:
let appDelegate = UIApplication.sharedApplication().delegate as! AppDelegate
appDelegate.changeRootViewControllerToSWRevealViewController()
Step-1
embed your login VC to NavigationController.
Step-2
on your login button action set the segue type as Modal
and call as
@IBAction func btnLogin(sender: AnyObject) {
self.performSegueWithIdentifier("openSWL", sender: self)
}
For flow understand purpose
For sample Project you can download here