implement login screen before swrevealcontroller

前端 未结 2 756
谎友^
谎友^ 2021-02-06 13:46

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

相关标签:
2条回答
  • 2021-02-06 14:06

    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()
    
    0 讨论(0)
  • 2021-02-06 14:13

    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

    0 讨论(0)
提交回复
热议问题