Implement login screen before swrevealcontroller

I just started learning iOS development, I successfully implemented SWRevealViewController, following the given online guide, everything works as expected.

Then I decided to add a login screen, which will be the first page that the user will see when the application is launched. I have taken the following steps:

  • Drop the UIViewController on the bulletin board
  • Set this as my 'initial view controller'
  • Added a button for this new view and created for testing for testing purposes.

But when I click on this button, it does nothing, therefore, after searching the Internet and trying to figure it out by one of my co-authors, unfortunately, I was not successful because of my lack of knowledge about this, someone will be kind enough , to give me some pointers to what I need to change, if anything, or which sections do I need to change so that this thread works properly?

Below is a screen shot of my current story.

enter image description here

Update

After adding the appropriate code to the application delegate file, I still get this error message:

enter image description here

+5
source share
2 answers

Step 1

embed your VC login in the NavigationController.

Step 2

when the login button is activated, enter the segment type as Modal and call

  @IBAction func btnLogin(sender: AnyObject) { self.performSegueWithIdentifier("openSWL", sender: self) } 

To understand the flow

enter image description here

For an example project, you can download here

+3
source

The layout of the storyboard looks good. I used SWRevealController as shown below:

After logging in (executing the logon service or some process of logging in), write the code below. This code will change the current rootViewController (in your case, it is LoginViewController ) to SWRevealController . So it will work. And when you log out, change rootViewController to LoginViewController .

 SWRevealViewController *controller = (SWRevealViewController *)[self.mainStoryboard instantiateViewControllerWithIdentifier:@"RevealViewController"]; [self.window setRootViewController:controller]; 

Remember to assign StoryboardID = "RevealViewController" in the Storyboard to SWRevealViewController .

Swift Code:

Add the function below 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 the function above in your login action method, as shown below:

  let appDelegate = UIApplication.sharedApplication().delegate as! AppDelegate appDelegate.changeRootViewControllerToSWRevealViewController() 
+1
source

All Articles