Iphone iOS:如何让ViewController A以模态方式呈现B,然后让B直接解除/转换到以模态方式呈现的C?

Iphone iOS:如何让ViewController A以模态方式呈现B,然后让B直接解除/转换到以模态方式呈现的C?,iphone,ios,objective-c,Iphone,Ios,Objective C,现在我有一个ViewController(“a”),它以模式显示用户的iPod库(“B”): 我通过授权从“A”中删除了以方式呈现的VC“B”: - (void)mediaPicker:(MPMediaPickerController *)mediaPicker didPickMediaItems:(MPMediaItemCollection *)mediaItemCollection { // Do stuff with selected item... // Set up

现在我有一个ViewController(“a”),它以模式显示用户的iPod库(“B”):

我通过授权从“A”中删除了以方式呈现的VC“B”:

- (void)mediaPicker:(MPMediaPickerController *)mediaPicker didPickMediaItems:(MPMediaItemCollection *)mediaItemCollection {
    // Do stuff with selected item...

    // Set up modal transition style and then dismiss
    [mediaPicker setModalTransitionStyle:UIModalTransitionStyleFlipHorizontal];
    [mediaPicker dismissViewControllerAnimated:YES completion:^{
        // Launch capture screen
        // DOING IT THIS WAY CLEARLY SHOWS VIEW "A" BEFORE WE SEE VIEW "C"
        // I'M LOOKING FOR A WAY I CAN DISMISS THE MODAL IPOD MUSIC PICKER
        // VIA "FLIP" DIRECTLY TO VIEW CONTROLLER "C" (WHICH DOES SOMETHING
        // WITH THE SELECTED SONG).
        [self performSegueWithIdentifier:@"captureViewController" sender:self];
    }];
}
有了这个实现,从技术上来说一切都正常。我不喜欢的是,ViewController A同时显示B和C的方式,用户可以在ViewController A关闭B之后和显示C之前看到它。我希望A显示B,然后B直接关闭/转换到C。我如何实现这一点


*更新:还要注意,如果我将手动segue调用放在完成块之外,那么我会在一次呈现两件事情时出错。如果将动画切换为“否”,则会出现不同的错误。

在情节提要中提供
captureViewController
标识符

- (void)mediaPicker:(MPMediaPickerController *)mediaPicker didPickMediaItems:(MPMediaItemCollection *)mediaItemCollection {
    // Do stuff with selected item...

    // Set up modal transition style and then dismiss

    UIStoryboard *mainStoryboard = [UIStoryboard storyboardWithName:@"STORYBOARDNAME" bundle:nil];
    UIViewController *vc = [mainStoryboard instantiateViewControllerWithIdentifier:@"captureViewController"];
    [self presentModalViewController:vc animated:NO];

    [mediaPicker setModalTransitionStyle:UIModalTransitionStyleFlipHorizontal];
    [mediaPicker dismissViewControllerAnimated:YES completion:nil];
}
试试这个

- (void)selectSong { // UIBarButtonSystemItemAdd target action
    MPMediaPickerController *picker = [[MPMediaPickerController alloc] init];
    picker.delegate = self;
 [self performSegueWithIdentifier:@"captureViewController" sender:self];
    }];
    [self presentViewController:picker animated:YES completion:NULL];
}

这看起来很有希望。我尝试了一下,收到了以下错误消息:
警告:尝试显示不在窗口层次结构中的视图此方法将captureViewController置于iPod歌曲选择器之前的屏幕上。用户从未获得选择歌曲的机会。
- (void)selectSong { // UIBarButtonSystemItemAdd target action
    MPMediaPickerController *picker = [[MPMediaPickerController alloc] init];
    picker.delegate = self;
 [self performSegueWithIdentifier:@"captureViewController" sender:self];
    }];
    [self presentViewController:picker animated:YES completion:NULL];
}