I am working with the MPMediaPickerController controller.
Right now I am able to select an item from the gallery using the following code:
MPMediaPickerController *controller = [[MPMediaPickerController alloc]initWithMediaTypes:MPMediaTypeAnyAudio];
controller.delegate = mediaDelegate._pickerDelegate;
[self presentViewController:controller animated:YES completion:nil];
NSLog(@"url :%@",singleton.url);
The intention is that my method should return the URL of the selected item. Instead I am getting null
for the URL because the line below the present view controller gets called as soon as view controller presented (it is not waiting for selection of item).
Is there any way to stop after presentViewController
, for selection of item and then return the selected item URL from the method ?
You need to implement the
MPMediaPickerControllerDelegate
delegate:When the user selects an item, that method will be called