UIImagePickerController crashing

Posted by Mike on Stack Overflow See other posts from Stack Overflow or by Mike
Published on 2010-04-28T20:31:07Z Indexed on 2010/04/29 5:57 UTC
Read the original article Hit count: 817

Filed under:
|
|
|

I am developing a project based on iPhone OS 3.2 This project uses UIImagePickerController to pick videos. I have managed to put a video inside the iPad simulator. Photos.app can see and play the video, that was created using an iPhone 3GS, but whey I try to use the UIImagePickerController, it simply crashes my app.

THis is the code I am using:

 if ([UIImagePickerController isSourceTypeAvailable:
   UIImagePickerControllerSourceTypePhotoLibrary]) {
  UIImagePickerController *picker = [[UIImagePickerController alloc] init];
  picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
    picker.mediaTypes = [UIImagePickerController availableMediaTypesForSourceType:picker.sourceType];//shows movies and photos on iPhone

  picker.delegate = self;
  picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;

  UIPopoverController *popover = [[UIPopoverController alloc] initWithContentViewController:picker];

  CGRect myRect = CGRectMake(0,0,100,100); // this is a random rect just for testing
  [popover presentPopoverFromRect:myRect inView:myMainView permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];

 }

after running this, the app crashes miserably with the following message

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Popovers cannot be presented from a view which does not have a window.'

Is there something wrong with the code or it is just the simulator crashing because it is unable to pick videos?

please refrain from recommending me to test on a real device. The problem is that I live outside the US and there's no iPad here soon.

thanks.

© Stack Overflow or respective owner

Related posts about iphone

Related posts about iphone-sdk