One day a group of friends encountered a problem saying that using Mpmediapickercontroller will crash.
[self presentviewcontroller:self. Mediapicker animated:YEScompletion:nil];
Two I run the next, on the real machine is OK, the simulator should add the following code
1.  mpmediapickercontroller does not run in the emulator. Apple points out that in the "Hello Music player" in the "Ipod Library Access Programming Guide". Note: To follow these steps, you need to screw up the emulator to have access to the music library that has been turned off by the 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];//would Throw an exception on 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 Lo Ad ") delegate:nil cancelbuttontitle:@" 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, click Run this app on device" Delegate:nil CA ncelbuttontitle:@ "OK" Otherbuttontitles:nil]; [Alert show]; #else [self performseguewithidentifier:@ "Showpickerviewsegue" sender:self]; #endif}
It's OK.
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Mpmediapickercontroller selecting local audio error running in simulator