开发者

switching between 2 different view controllers that are presented modaly

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" bun开发者_Python百科dle: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!


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜