0

现在我有一个 ViewController(“A”),它以模态方式呈现用户的 iPod 库(“B”):

// This works great
- (void)selectSong { // UIBarButtonSystemItemAdd target action
    MPMediaPickerController *picker = [[MPMediaPickerController alloc] init];
    picker.delegate = self;
    [self presentViewController:picker animated:YES completion:NULL];
}

我通过委托从“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 的方式,用户可以在它解除 B 之后和呈现 C 之前看到 ViewController A。我希望 A 呈现 B,然后 B 直接解除/过渡到C. 我怎样才能做到这一点?

*更新:还要注意,如果我将手动 segue 调用放在完成块之外,那么我会收到关于同时呈现两件事的错误。如果我将动画切换为 NO,我会得到一个不同的错误。

4

2 回答 2

0

试试这个,

- (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];
}
于 2013-06-18T05:48:53.507 回答
0

在情节提要中给出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];
}
于 2013-06-18T05:45:27.850 回答