Home:ALL Converter>iOS - Present View controller immediately after dismissing an other view controller

iOS - Present View controller immediately after dismissing an other view controller

Ask Time:2014-03-01T08:43:22         Author:Adnan

Json Formatter

I have three View Controller VC1,VC2 and VC3.

VC2 is of a 3rd party library and it is presented on VC1.

Then VC2 dismissed itself and send a callback to VC1 and VC1 try to present VC3 on itself but failed.

Is there some way to present VC3 immediately after dismissing VC2 ?

-(void)onDismisLoginVC{

    MessageVC *messageVC = [[MessageVC alloc] initWithNibName:@"MessageVC" bundle:nil];
    [self.navigationController presentViewController:messageVC animated:YES completion:NULL];

}

Unfortunately I can not use ^completion block of dismissing presented viewcontroller in VC2 because I am just receiving a callback to this method and can't edit code of VC2.

Author:Adnan,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/22108538/ios-present-view-controller-immediately-after-dismissing-an-other-view-control
nhgrif :

I know we all always put nil for the completion block... but it actually does have some use. I assure you.\n\n[self dismissViewControllerAnimated:YES completion:^{\n //code to be executed with the dismissal is completed\n // for example, presenting a vc or performing a segue\n }];\n",
2014-03-01T00:45:31
pkarc :

This is the one I use to dismiss a Facebook login view controller.\n\nUIViewController *theTrick = self.presentingViewController;\nUIViewController *toPresent = [self.storyboard instantiateViewControllerWithIdentifier:@\"toPresentViewController\"];\n\n[self dismissViewControllerAnimated:YES completion:^{\n [theTrick presentViewController:toPresent animated:YES completion:nil];\n}];\n",
2014-12-04T15:44:16
yy