我正在开发一个应用程序。我需要从电话库中获取音乐文件。为此我使用 MPMediaPickerCOntroller。但它不会触发 didpickingitem 委托方法。我的代码如下所示。
- (void)viewDidLoad
{
[super viewDidLoad];
MPMediaPickerController *picker =[[MPMediaPickerController alloc] initWithMediaTypes: MPMediaTypeMusic];
picker.delegate = self;
picker.allowsPickingMultipleItems = YES;
picker.prompt =@"Add songs to play";
[self presentModalViewController:picker animated: YES];
}
- (void) mediaPicker: (MPMediaPickerController *) mediaPicker didPickMediaItems: (MPMediaItemCollection *) mediaItemCollection
{
NSLog(@"sdfadsf");
NSLog(@"%@",mediaItemCollection);
NSArray *slist=[mediaItemCollection copy];
NSLog(@"%@",slist);
}