I think that by the time you close the first view controller, [self.navigation presentmodal ..] does not have its own to open a new one.
You can do it:
use a boolean to indicate whether this next time this controller appears (when you close the one you are currently trying to open), it should close and implement this function in the viewDidApper: method, for example:
@interface FirstViewController : UIViewController {
and in the .m file,
-(void)viewDidAppear:(BOOL)animated{ if(close) [self dismissModalViewControllerAnimated:NO]; else [super viewDidAppear:animated]; }
Now, to open the new controller, do the following:
-(IBAction)openSecondController:(id)sender{ //.. SecondViewController* controller = [[SecondViewController alloc] initWithNibName:@"SecondViewController" bundle:nil]; close = YES; [self presentModalViewController:controller animated:NO]; }
now that you close the second, the first will be closed. has no visible side effects in my applications.
not the cleanest way, but I did not find a better one. greetings
eiran
source share