MPMediaPickerController 选取本地音频 在模拟器运行出错

一 今天有群友遇到问题说使用MPMediaPickerController 会崩溃。

completion

二 我运行了下,在真机上是ok的,模拟器应该加上以下代码

1.MPMediaPickerController不会在模拟器中运行。苹果公司指出这下“你好音乐播放器”中的“iPod库访问编程指南”中。该说明称: 注意:要按照这些步骤,,你需要拧置备 该模拟器有没有访问拧开了iPod的音乐库。MPMediaPickerController *picker = [[MPMediaPickerController alloc] initWithMediaTypes:MPMediaTypeAnyAudio];[picker setDelegate:self];[picker setAllowsPickingMultipleItems:YES];[picker setPrompt:NSLocalizedString(@"Add songs to play","Prompt in media item picker")];@try { [picker loadView]; // Will throw an exception in iOS simulator [self presentViewController:picker animated:YES completion:nil];}@catch (NSException *exception) { [[[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Oops!",@"Error title")message:NSLocalizedString(@"The music library is not available.",@"Error message when MPMediaPickerController fails to load")delegate:nilcancelButtonTitle:@"OK"otherButtonTitles:nil] show];}

2.storyboard(故事板),你可以尝试一下:

– (IBAction)showPicker:(id)sender{#if TARGET_IPHONE_SIMULATOR UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"playerTest"message:@"Media picker didn't work in simulator, please run this app on device"delegate:nilcancelButtonTitle:@"OK"otherButtonTitles:nil]; [alert show];#else [self performSegueWithIdentifier:@"ShowPickerViewSegue" sender:self];#endif}ok了。

版权声明:本文为博主原创文章,未经博主允许不得转载。

未曾失败的人恐怕也未曾成功过。

MPMediaPickerController 选取本地音频 在模拟器运行出错

相关文章:

你感兴趣的文章:

标签云: