lundi 29 décembre 2014

uiimagepickercontroller didfinishpickingmediawithinfo NOT CALLED when selecting a video from the library

I am writing an app where the user can select photos and videos from the library. I want to implement my own video player when a video is selected but the app immediately starts the default video player that has the choose button.


The didfinishpickingmediawithinfo function does not get called. This only happens when a video is selected. I can display a selected photo to screen because the delegate method gets called in the case of photo selection.


Why is the delegate method for the picker not being called only when a video is selected from the library?


Code for library button click:



//Library access function displays photos and videos stored on the device
- (IBAction)selectPhoto:(UIButton *)sender {

UIImagePickerController *picker2 = [[UIImagePickerController alloc] init];
picker2.delegate = self;
picker2.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
picker2.mediaTypes =[UIImagePickerController availableMediaTypesForSourceType:picker2.sourceType];
picker2.allowsEditing = NO;

self.picker2 = picker2;

[self.picker dismissViewControllerAnimated:YES completion:^{
[self presentViewController:self.picker2 animated:YES completion:NULL];}];


}


I do include the delegates in the view controller. Lots of questions I have researched point out the lack of inclusion within the header to the view controller but I assure you they are there.


Here is the code for the inclusion:



@interface ViewController : UIViewController <UIImagePickerControllerDelegate,UINavigationControllerDelegate,UIGestureRecognizerDelegate>


I have placed NSLog statements within the delegate method and I see that they are executed in all other cases when using the picker. However, in the case of video selection the NSLog statements do not appear.


If anyone has had this problem before and come up with a solution, please share it. I have searched for many days and have not found a solution to this problem.


A person in this thread had the same issue but the problem was never solved.


Everything this question has to offer as a solution, I have implemented within my program.




Aucun commentaire:

Enregistrer un commentaire