简体   繁体   中英

Dismiss View Controller and Presenting another View Controller

I am using 3 screens

1)VC1--Storyboard

2)VC2 --Xib

3)VC3- Storyboard

VC1 is a User screen ,if user enters userid and press login user able to move VC2-Xib

VC2 is a Passcode screen , if user enters 4 digit pin user able to move VC3

What here i am facing is ,

after user enters 4 digit pin it is moving to VC1 ie users screen .i need to move VC2 This is my code ,this is the line which i did to dismiss the VC2 ,

 [self dismissViewControllerAnimated:YES completion:nil];

it is going to VC1 after this dismiss view controller .Please give example how to present VC3 after dismiss this view controller.Please help me to do this

If you want to present vc3 from vc1 modally after dismissing vc2, you can present vc3 programmatically in the completion block of your dismiss method which you currently have set to nil. For instance you could write:

[self dismissViewControllerAnimated:YES completion:^{
    UIViewController *vc3 = [[UIStoryboard storyboardWithName:@"storyboardName" bundle:nil] instantiateViewControllerWithIdentifier:@"vc3Identifier"];
    [self presentViewController:vc3 animated:YES completion:nil];
}];

Of course you have to use the correct storyboard name and the view controller's storyboard identifier that you should have set in the storyboard.

If you're using a navigation controller you can also push to the navigation controller which you could use:

[self.navigationController pushViewController:vc3 animated:YES];

instead of:

[self presentViewController:vc3 animated:YES completion:nil];

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM