Iphone 在模式显示的两个不同视图控制器之间切换

Iphone 在模式显示的两个不同视图控制器之间切换,iphone,objective-c,Iphone,Objective C,我有一个主UIViewController,它是在启动时创建的,我只使用它在2个不同的视图控制器之间切换 下面是执行切换的代码: - (void)imagePickerController:(UIImagePickerController*)picker didFinishPickingMediaWithInfo:(NSDictionary*)info { [self dismissModalViewControllerAnimated:NO]; PreviewView *p

我有一个主UIViewController,它是在启动时创建的,我只使用它在2个不同的视图控制器之间切换

下面是执行切换的代码:

- (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];
}
在第一种方法中,开关工作,但在第二种方法中不工作。我想知道为什么


谢谢

在第二种方法中,您首先要求
self
退出。然后,再次要求
self
显示一个新的视图控制器。这是不对的。您想让另一个ViewController的“父级”显示UIImagePickerController


您可以尝试将dismise移到present之后。

只是想知道,dismissModalViewControllerAnimated:和presentModalViewController:方法中使用的“动画”参数在每个方法中都不同吗?是的,这是因为我希望previewView显示/取消动画,而不是imagePicker。谢谢在介绍新控制器之前,我应该先关闭当前控制器(已在另一种方法中介绍),不是吗?