在iOS模拟器中使用MPMediaPickerController时出现运行时错误 [英] Runtime error when using MPMediaPickerController in iOS Simulator
问题描述
当我尝试在iOS模拟器上使用 MPMediaPickerController
运行应用程序时会发生以下情况。
The following happens when I try to run an app using the MPMediaPickerController
on the iOS Simulator.
2012-05-28 22:26:42.416 My App[48426:11f03] Could not load source: 3
2012-05-28 22:26:42.418 My App[48426:11f03] *** Assertion failure in -[MPMediaPickerController loadView], /SourceCache/MediaPlayer_Sim/MobileMusicPlayer-1391.72/SDK/MPMediaPickerController.m:86
2012-05-28 22:26:42.419 My App[48426:11f03] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Unable to load iPodUI.framework'
这是我的App / Xcode / iOS模拟器中的一些问题,还是iOS模拟器根本不支持 MPMediaPickerController
?如果没有,除了在物理设备上运行它之外还有其他选择吗?
Is this some problem in my App/Xcode/iOS Simulator, or does the iOS Simulator simply not support the MPMediaPickerController
? If not, any alternatives, besides running it on a physical device?
推荐答案
MPMediaPickerController在模拟器中不起作用。 Apple在 iPod库访问编程指南在Hello Music Player下。该说明说:
MPMediaPickerController does not work in the Simulator. Apple notes this in the "iPod Library Access Programming Guide" under "Hello Music Player". The note says:
注意:要执行这些步骤,您需要配置设备,因为模拟器无法访问
设备的iPod库。
Note: To follow these steps you’ll need a provisioned device because the Simulator has no access to a device’s iPod library.
为了防止断言,您可以随时检查是否可以在代码中执行此操作(代码如下) ARC和iOS SDK 5.0)。
To prevent the assertion you can always check if you can access the do this in your code (code bellow uses ARC and iOS SDK 5.0).
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:nil
cancelButtonTitle:@"OK"
otherButtonTitles:nil] show];
}
这篇关于在iOS模拟器中使用MPMediaPickerController时出现运行时错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!