I am designing an iOS app using XCode 4.2’s storyboard feature. The app has a login screen that takes a username and password and has a button to log in. Pushing the login button triggers a push seque to another view controller. However, I want the seque to wait until the login comes back successful before proceeding to the next view controller.
I know about prepareForSegue:sender: but heres my issue: the login call is asynchronous. I therefore cannot perform the login there.
Is there someway around this? Can I create a seque in the storyboard that is only triggered when I want it to be (as opposed to when a button is clicked)?
Ok, I have figured it out. I had defined a segue from a
UIButtonto the nextUIViewController. As defined in this manner, there is no way to conditionally execute the segue.Instead of putting the segue on the button, I made a segue from the first
UIViewControllerto the otherUIViewController. This defines the segue, but associates no action with it. From there I can simply callperformSegueWithIdentifier:sender:when I want that segue to execute (in my case being when the async task is complete).The main advantage of this for me is that IB maintains its structure.
Big thanks to @cli_hlt for pointing me in the right direction (+1).