views:

52

answers:

1

Hello guys,

I have a main UIViewController that is create at startup that I only use to switch between 2 different view controllers that are presented modaly.

Here my code that does the switch:

- (void)imagePickerController:(UIImagePickerController*)picker didFinishPickingMediaWithInfo:(NSDictionary*)info {

    [self dismissModalViewControllerAnimated:NO];

    PreviewView *previewViewController = [[PreviewViewController alloc] initWithNibName:@"PreviewView" bundle:nil];
    previewViewController.delegate = self;
    [self presentModalViewController:previewViewController animated:YES];
    [previewViewController release];
}

- (void)previewViewControllerdoneButtonPressed:(AnotherViewController*)controller  {

    [self dismissModalViewControllerAnimated:YES];

    UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];
    imagePicker.delegate = self;
    [self presentModalViewController:imagePicker animated:NO];
    [imagePicker release];
}

In the first method, the switch works but not in the second. I will like to understand why.

Thanks!

A: 

In the second method you first ask self to dismiss. Then you ask self again to present a new view controller. This is not correct. You want to ask the 'parent' of AnotherViewController to show the UIImagePickerController.

One thing you could try is to move the dismiss after the present.

St3fan
I shoud dismiss the current controller (which have been presented in the other method) before presenting the new one, no?
Yoshi