Reputation: 305
I have one button in main screen. When user clicks "Search" button, I will search that user in database whether he signed in or not.
If he already signed in, I will show "Sign Out" screen. If not, I want to show "Sign In" screen.
I connected "Search" button and "Sign In" view controller with push segue because I want to pass some data from main screen.
I tried to connect "Sign Out" view controller with "Search" button as well but I couldn't connect them.
How could I connect two view controllers with one button?
Yeah, with push segue and want to pass some values too. Now I use prepareForSegue
method to pass data. Could anybody help me please? (If my question is too basic for you, I'm really sorry for that because I'm still a starter for iOS development.)
Thanks in advance!
Upvotes: 0
Views: 773
Reputation: 2654
You can do that using code -
Create IBAction method for Search Button UIControlEventTouchUpInside event.
Now check user SignIn or SignOut within IBAction method and push respective viewController using below code
SignINViewController *controller = [self.storyboard instantiateViewControllerWithIdentifier:@"SignINViewController"]; [self.navigationController pushViewController:controller animated:YES];
Don't forgot to provide Storyboard ID & Restoration ID for your viewControler from storyboard.
Upvotes: 3