hani hani - 18 days ago 4x
iOS Question

Pushing two Different view controllers in one button action-iOS

My iOS application has four tabs that displays different information.

In my second tab viewController I have one button lets name it as button1 in that button1 action i have navigated to SignInViewController screen and in my third tab view controller is loginViewController.

In both the ViewControllers I have option to register and as well as already existed user can logged in both the ViewControllers.So here in SignInViewController I have a button named it as registerButton. Now in this registerButton action I have pushed RegisterViewController and same as SignInViewController in loginViewController also i have button named it as registerButton2. Now in this registerButton2 Action i have pushed same RegisterViewController.

Here now what i want exactly is in RegisterViewController I have a button lets name it as SaveButton in SaveButtonAction if I am gone through from SignInViewController to RegisterViewController then in SaveButtonAction i want to push ShippingViewController and if I am gone through from loginViewController to RegisterViewController then in SaveButtonAction i want to push `AccountViewController.

in short (1)tabbaritem2-->SignInViewController-->RegisterViewController-->ShippingViewController (2)tabbaritem3-->loginViewControoler-->RegisterViewController-->AccountViewController

I have tried following code in SaveButtonAction but its does not working.

Here is my code:

- (IBAction)SaveButtonAction:(id)sender{

if(_tabBarController.tabBarItem.tag == 2){

UIStoryboard *story = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
ShippingViewController *shipVc = [story instantiateViewControllerWithIdentifier:@"ShippingViewController"];
[self.navigationController pushViewController:shipVc animated:YES];

else if(_tabBarController.tabBarItem.tag == 3){

UIStoryboard *story = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
AccountViewController *acntVC = [story instantiateViewControllerWithIdentifier:@"AccountViewController"];
[self.navigationController pushViewController:acntVC animated:YES];



kindly help.Thanks in Advance.


//This code when you push to RegisterVC from LoginVC. Similar thing for other case but assign @"signin" instead of @"login".

UIStoryboard *story = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
RegisterViewController  *registerVc = [story instantiateViewControllerWithIdentifier:@"RegisterViewController"];
registerVc.imFromLogin = @"login";
[self.navigationController pushViewController:registerVc animated:YES];
- (IBAction)SaveButtonAction:(id)sender{
    if([_imFromLogin isEqualToString:@"login"])
         [self performSegueWithIdentifier:@"regToAccount" sender:nil];
    }else if ([_imFromLogin isEqualToString:@"signin"]) {
        [self performSegueWithIdentifier:@"registerToShipping" sender:nil];