jakespracher / Snapchat-Swipe-View

Handy four way snapchat style scrolling navigation
MIT License
143 stars 19 forks source link

Cannot set custom ViewController to Initial #6

Closed boshd closed 7 years ago

boshd commented 8 years ago

Alright so let me just give you an overview of my system. I have a intial root view (home) that contains two buttons (sign up - login) where each of these buttons has its own viewcontroller. The LoginViewController has a method as such:

            if ((user) != nil) {
                let alert = UIAlertView(title: "Success", message: "Logged In", delegate: self,   cancelButtonTitle: "OK")
                alert.show()

                dispatch_async(dispatch_get_main_queue(), { () -> Void in
                    let viewController:UIViewController = UIStoryboard(name: "Main", bundle: nil).instantiateViewControllerWithIdentifier("View")
                    self.presentViewController(viewController, animated: true, completion: nil)
                })

            } else {
                let alert = UIAlertView(title: "Error", message: "Hmm, that doesn't seem  right. Try again.", delegate: self, cancelButtonTitle: "OK")
                alert.show()
            }

Where if login is successful it takes you to the ViewController w/ identifier "Main". Thing is that im having trouble setting the initial controller to the "home" view when using your approach, and i think this is due to the code you provided for the appDelegate. Even though I set the Home viewcontroller to initial, it still takes me to the middleviewcontroller. what am i doing wrong?

jakespracher commented 7 years ago

Yes you are right, if this code is in your app delegate: self.window?.rootViewController = snapContainer self.window?.makeKeyAndVisible()

you will be going to the snapchat style view first. That code in the readme is just an example, you'll need to modify it to suit your needs. What you want is pretty easy though. I would recommend creating a new storyboard for your login flow, if the user isn't logged in, go to that storyboard from your app delegate, else go to mine. Then you could link the login storyboard to the main storyboard so when you're done logging in it takes you to the snapchat view.

jakespracher commented 7 years ago

Updated the readme to clarify