0
votes

Right now I have a ViewController ("A") that presents a user's iPod library ("B") modally:

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

I dismiss the modally presented VC, "B" from within "A" via delegation:

- (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];
    }];
}

With this implementation, technically everything works. What I don't like is that the way ViewController A is presenting both B and C, the user can see ViewController A after it dismisses B and before it presents C. I want A to present B and then B to dismiss/transition directly to C. How can I achieve this?

*Update: Also note that if I put the manual segue call outside the completion block, then I get errors about presenting two things at once. If I switch animated to NO, I get a different error.

2

2 Answers

0
votes

Give captureViewController an identifier in the storyboard.

- (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];
}
0
votes

try with this,

- (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];
}