3

I'm using the UIImagePickerController in iOS 4.2.1 on an iPhone 3Gs. I've previously used the deprecated method

- (void)imagePickerController: didFinishPickingImage: editingInfo:

without a problem. I have another app using the new didFinishPickingMediaWithInfo API in another app, and the method is never getting called by the picker once media is chosen.

//MyViewController.h
    @interface MyViewController : UIViewController < UIImagePickerControllerDelegate, UINavigationControllerDelegate>

//MyViewController.m

    if([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypePhotoLibrary]) {
        UIImagePickerController *picker =  [[UIImagePickerController new] autorelease];
        picker.delegate = self;
        picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
        picker.mediaTypes =  [[NSArray alloc] initWithObjects: (NSString *) kUTTypeMovie, nil];
        picker.videoQuality = UIImagePickerControllerQualityTypeHigh;
        picker.allowsEditing = NO;
        [self presentModalViewController:picker animated:TRUE];
    }

    - (void)imagePickerController:(UIImagePickerController *)picker imagePickerController:didFinishPickingMediaWithInfo:(NSDictionary *)editingInfo{
        //**NEVER CALLED**
    }
1
  • is that code block getting called? by which I mean -- does [UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypePhotoLibrary] return YES? Commented Dec 6, 2010 at 4:09

5 Answers 5

1

you have

- (void)imagePickerController:(UIImagePickerController *)picker imagePickerController:didFinishPickingMediaWithInfo:(NSDictionary *)editingInfo

where you probably want

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
Sign up to request clarification or add additional context in comments.

Comments

0

You have this: - (void)imagePickerController:(UIImagePickerController *)picker imagePickerController:didFinishPickingMediaWithInfo:(NSDictionary *)editingInfo

Look like you repeated the 'imagePickerController:' part of that method.

Comments

0

Putting the picker in the autorelease pool may be your problem -- it probably doesn't stick around long enough to call its delegate. Retain it instead:

UIImagePickerController *picker = [[UIImagePickerController alloc] init];

And then in the delegate you can release it:

[picker dismissModalViewControllerAnimated:YES];
[picker release];

Comments

0

It may be that this line:

if([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypePhotoLibrary]) {

is returning false. This happens if the user's photo library is empty; this would be true on the iPhone simulator, for example.

EDIT: As the other examples show, you've also mistyped the delegate method. It should be:

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info

Comments

0

This is program that i have used to upload video to webservice through iOS 4.2 on 3g

-(void)uploadeVideoClicked{
    UIImagePickerController *ipc = [[UIImagePickerController alloc] init];
    ipc.sourceType =  UIImagePickerControllerSourceTypePhotoLibrary;
    ipc.allowsEditing=NO;
    ipc.videoQuality = UIImagePickerControllerQualityTypeMedium;
    ipc.mediaTypes =[UIImagePickerController availableMediaTypesForSourceType:ipc.sourceType];     
    ipc.mediaTypes = [NSArray arrayWithObject:(NSString *)kUTTypeMovie];
    ipc.delegate = self;
    [self presentModalViewController:ipc animated:YES];
}

- (void)imagePickerController:(UIImagePickerController *)picker  didFinishPickingMediaWithInfo:(NSDictionary *)info

{
    NSMutableDictionary *infoDict = [[NSMutableDictionary alloc]init];
    NSString *mediaType = [info objectForKey:UIImagePickerControllerMediaType];
    if ([mediaType isEqualToString:@"public.image"]){
        UIAlertView *myAlertView = [[UIAlertView alloc] initWithTitle:@"" message:@"You Select a image Please select Movie" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
        [myAlertView show];
        [myAlertView release];
    } else if ([mediaType isEqualToString:@"public.movie"]){
        NSURL *videoURL = [info objectForKey:UIImagePickerControllerMediaURL];
        mAppDelegate.uploadType = @"Video";
        NSData *webData = [NSData dataWithContentsOfURL:videoURL];
        [infoDict setValue:webData forKey:@"VideoUrl"];
        [infoDict setValue:[[mAppDelegate.userInfoArray objectAtIndex:1]valueForKey:@"user_id"] forKey:@"user_id"];
        //Call webService to upload video ;
    }
    [picker dismissModalViewControllerAnimated:YES];
    [infoDict release];
}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.