2

I'm trying to present an UIImagePickerController. It works fine on simulator, but after few times of presenting, I get an error in the console.

More than maximum 5 filtered album lists trying to register. This will fail.

Here is the code:

- (IBAction)imageSelectorPressed:(id)sender 
{
    UIImagePickerController* picker = [[[UIImagePickerController alloc] init] autorelease];
    if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypePhotoLibrary])
    {
        // Set source to the Photo Library
        picker.sourceType =UIImagePickerControllerSourceTypePhotoLibrary;

    }
    picker.delegate = self; 
    UIPopoverController *popover = [[UIPopoverController alloc] initWithContentViewController:picker];
    self.imagePopOverController = popover;
    [self.imagePopOverController setDelegate:self];
    [self.imagePopOverController presentPopoverFromRect:[kepekBtn frame] inView:self.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
    [popover release]; 
}

-(void)popoverControllerDidDismissPopover:(UIPopoverController *)popoverController
{
    [popoverController dismissPopoverAnimated:YES];
    [self setImagePopOverController:nil];
}

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
    [self.imagePopOverController dismissPopoverAnimated:NO];
    [image setImage:[info objectForKey:@"UIImagePickerControllerOriginalImage"]];
    picker = nil;
    [self setImagePopOverController:nil];
}

-(void)imagePickerControllerDidCancel:(UIImagePickerController *)picker
{
    [self.imagePopOverController dismissPopoverAnimated:NO];
    picker = nil;
    [self setImagePopOverController:nil];
}

UPDATE: I've checked the contact app on the iPad. Edited a person, and it has a same error in the console log. BUT it is not crashing, while my app is. So the proper question: How can I fix it?

Mehul Mistri
  • 15,037
  • 14
  • 70
  • 94
MetaImi
  • 274
  • 2
  • 13
  • Is there a particular line the debugger highlights when it crashes? Or does the app 'simply' close (= go to sprinboard) – basvk Jul 27 '12 at 09:09
  • simply close, the debugger jumps to the main () method. :( Nothing informal. – MetaImi Jul 27 '12 at 09:18
  • Maybe this helps: http://stackoverflow.com/questions/9019838/using-presentmodalviewcontroller-with-uiimagepickercontroller-causing-crash-on-i/9019946#9019946 Else you could try to alloc / initialize the `UIImagePIckerController` in the `viewDidLoad` method and release it when the view unloads, so you won't create a new picker everytime your press a button. But just re-use the existing one – basvk Jul 27 '12 at 09:22

0 Answers0