Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UIImagePickerController intermittently stops responding after tapping "Use" button

I have an app that records video. The app is a mixture of cocos2d and UIKit though the part using the UIImagePickerController is all UIKit.

The Problem: After taking a video, when you tap the "Use" button, the button changes to selected state and then nothing happens. The "Retake" button is disabled. You can still Play/Pause the video but the view never dismisses and - (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info is never called.

The problem happens on long and short (<5 second) videos. Causing memory warnings did not reproduce the issue. Changing audio sessions before launching the image picker did not reproduce the issue either.

I have been unable to cause the issue. It happens only occasionally. Any ideas?

Here is the code that presents the UIImagePickerController

  UIImagePickerController *tmpVC = [[UIImagePickerController alloc] init];
  tmpVC.delegate = self;
  tmpVC.allowsEditing = YES;
  // First get the right media types for the right source
  NSArray *types = nil;
  if (useCamera)
  {
    types = [UIImagePickerController availableMediaTypesForSourceType:UIImagePickerControllerSourceTypeCamera];
    tmpVC.sourceType = UIImagePickerControllerSourceTypeCamera;
  }
  else
  {
    types = [UIImagePickerController availableMediaTypesForSourceType:UIImagePickerControllerSourceTypePhotoLibrary];
    tmpVC.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
  }

  // Then see if "movie" is in there
  for (NSString *mediaType in types)
  {
    if ([mediaType isEqualToString:(NSString*)kUTTypeMovie])
    {
      tmpVC.mediaTypes = [NSArray arrayWithObjects:(NSString*)kUTTypeImage,(NSString*)kUTTypeMovie,nil];
      tmpVC.videoQuality = UIImagePickerControllerQualityTypeHigh;
    }
  }

  // Present the configured controller
  [self presentModalViewController:tmpVC animated:YES];
  [tmpVC release];
like image 941
Ross Avatar asked Mar 17 '11 20:03

Ross


2 Answers

Are you testing the app in the Simulator? Try testing it on a device and see if it does the same. I remember that I had a similar problem where I couldn't select a video with the picker in the Simulator because the application will just get "stuck" after I pressed the Use button.

like image 99
Mihai Fratu Avatar answered Oct 11 '22 18:10

Mihai Fratu


I would look else where in your code, is it called in a if statement? Did you alloc and init the thing that calls the - (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info. Those are just some little things I would look for, plus call a NSLog() where you see the call the function to know it has been called or there could be an error there.

like image 30
Milk Tea Avatar answered Oct 11 '22 19:10

Milk Tea