gpt4 book ai didi

objective-c - 通过 MPMediaPickerController 选择音频

转载 作者:行者123 更新时间:2023-12-05 03:14:46 25 4
gpt4 key购买 nike

您好,我正在使用 MPMediaPickerController 从电话库中选取音频文件。但它给了我空白屏幕。我不明白为什么会这样。我在模拟器上运行应用程序。这是我的代码

- (IBAction)selectFile:(UIButton *)sender{

MPMediaPickerController *mediaPicker = [[MPMediaPickerController alloc] initWithMediaTypes: MPMediaTypeMusic];
mediaPicker.delegate = self;
mediaPicker.allowsPickingMultipleItems = YES;
mediaPicker.prompt = @"Select Your Favourite Song!";
[mediaPicker loadView];
[self.navigationController presentViewController:mediaPicker animated:YES completion:nil]; }

最佳答案

对于那些想在 Swift 中得到答案的人:

@IBAction func openMediaPickerController(sender: AnyObject) {
let picker = MPMediaPickerController()
picker.delegate = self
picker.allowsPickingMultipleItems = true
picker.prompt = NSLocalizedString("Chose audio file", comment: "Please chose an audio file")
self.presentViewController(picker, animated: true, completion: nil)
}
func mediaPickerDidCancel(mediaPicker: MPMediaPickerController) {
self.dismissViewControllerAnimated(true, completion: nil)
}
func mediaPicker(mediaPicker: MPMediaPickerController, didPickMediaItems mediaItemCollection: MPMediaItemCollection) {
//run any code you want once the user has picked their chosen audio
}

关于objective-c - 通过 MPMediaPickerController 选择音频,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22907074/

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