gpt4 book ai didi

ios - 无法在 iOS 8.1.3 上关闭 MPMediaPickerController

转载 作者:行者123 更新时间:2023-12-01 16:36:00 27 4
gpt4 key购买 nike

我可以看到歌曲列表并选择歌曲。但是我不能在按下“完成”时关闭 View Controller 。我已经尝试过 PresentViewController,因为不推荐使用 Modal Controller 。

- (IBAction) showMediaPicker: (id) sender {

picker =
[[MPMediaPickerController alloc] initWithMediaTypes: MPMediaTypeAnyAudio];

picker.delegate = self;
picker.allowsPickingMultipleItems = YES;
picker.prompt = NSLocalizedString (@"AddSongsPrompt", @"Prompt to user to choose some songs to play");

[[UIApplication sharedApplication] setStatusBarStyle: UIStatusBarStyleDefault animated:YES];
[self.picker removeFromParentViewController];
[self presentViewController:picker animated:YES completion:nil];
// [picker release];
}


// Responds to the user tapping Done after choosing music.
- (void) mediaPicker: (MPMediaPickerController *) mediaPicker didPickMediaItems: (MPMediaItemCollection *) mediaItemCollection {
[self.picker removeFromParentViewController];
[self dismissViewControllerAnimated:YES completion:nil];
//
[self.delegate updatePlayerQueueWithMediaCollection: mediaItemCollection];
// [self.mediaItemCollectionTable reloadData];

// [[UIApplication sharedApplication] setStatusBarStyle: UIStatusBarStyleBlackOpaque animated:YES];
}

我也尝试过 RemovefromSuperview ,似乎没有任何效果。我正在 iPhone 6 模拟器和带有 iOS 8.1.3 的 iPhone 5 上对此进行测试。

任何人???

最佳答案

我测试了您的代码并删除了一些对 removeFromParentViewController: 的调用因为我认为它们没有必要。

- (IBAction)showMediaPicker:(id)sender {
MPMediaPickerController *picker = [[MPMediaPickerController alloc] initWithMediaTypes:MPMediaTypeAnyAudio];

picker.delegate = self;
picker.allowsPickingMultipleItems = YES;
picker.prompt = @"Some Prompt";

[self presentViewController:picker animated:YES completion:nil];
}

// mediaPicker:didPickMediaItems: will be called if at least one song was selected
- (void)mediaPicker:(MPMediaPickerController *)mediaPicker didPickMediaItems:(MPMediaItemCollection *)mediaItemCollection {
[mediaPicker dismissViewControllerAnimated:YES completion:nil];
}

// mediaPickerDidCancel: will be called if no songs were selected
- (void)mediaPickerDidCancel:(MPMediaPickerController *)mediaPicker {
[mediaPicker dismissViewControllerAnimated:YES completion:nil];
}

确保您的 .h -文件包括 MPMediaPickerControllerDelegate协议(protocol)。

关于ios - 无法在 iOS 8.1.3 上关闭 MPMediaPickerController,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28266300/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com