Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8966331
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T17:00:13+00:00 2026-06-15T17:00:13+00:00

I am getting an error / crash on iPad only when using the following

  • 0

I am getting an error / crash on iPad only when using the following code, iPhone works fine.

It is basically when trying to load the gallery to pick an image.

The debug error is;
“On iPad, UIImagePickerController must be presented via UIPopoverController'”

-(void) actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex{
    if (buttonIndex == 0) {
        if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypePhotoLibrary]) {
            UIImagePickerController *picker = [[UIImagePickerController alloc] init];
            picker.delegate = self;
            picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
            [self presentModalViewController:picker animated:YES];
            [picker release];
        }
        else {
            UIAlertView *alert = [[UIAlertView alloc]
                                  initWithTitle:@"Error accessing photo library"
                                  message:@"Device does not support a photo library"
                                  delegate:nil
                                  cancelButtonTitle:@"Abort!"
                                  otherButtonTitles:nil];
            [alert show];
            [alert release];
         }

    }
        if (buttonIndex == 1) {


        if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {
            UIImagePickerController *picker = [[UIImagePickerController alloc] init];
            picker.delegate = self;
            picker.allowsEditing = YES;
            picker.sourceType =UIImagePickerControllerSourceTypeCamera; 
            [self presentModalViewController:picker animated:YES];
            [picker release];
        }
        else {
            UIAlertView *alert = [[UIAlertView alloc]
                                  initWithTitle:@"Error accessing Camera"
                                  message:@"Device does not support a Camera"
                                  delegate:nil
                                  cancelButtonTitle:@"Abort!"
                                  otherButtonTitles:nil];
            [alert show];
            [alert release];
        }

        }


    }


    -(void) imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info{
        NSLog(@"the info opf picker is %@",info);
        NSAutoreleasePool *pool=[[NSAutoreleasePool alloc]init];
        NSData *imageData;

        if ([info objectForKey:UIImagePickerControllerEditedImage]) {
            UIImage *image2=[info objectForKey:UIImagePickerControllerEditedImage];
            //UIImage *myscaledImage=[self scaleImage:image2 toSize:CGSizeMake(18, 24)];
            //imageData = UIImagePNGRepresentation(myscaledImage);

            imageData=UIImageJPEGRepresentation(image2, .4);
            NSLog(@"the lenght of the edited image data is %d",[imageData length]);

        }
        else {
            UIImage *image=[info objectForKey:UIImagePickerControllerOriginalImage];

            //UIImage *myscaledImage=[self scaleImage:image toSize:CGSizeMake(18, 24)];
            //imageData = UIImagePNGRepresentation(myscaledImage);

            imageData=UIImageJPEGRepresentation(image, .6);
            NSLog(@"the lenght of the image dataa is %d",[imageData length]);

        }


        NSDictionary *tempDict=[NSDictionary dictionaryWithObjectsAndKeys:imageData,@"Image",@"Theme",@"Cell_Text",nil];
    //  NSLog(@"the custom array%@ and the row =%d", customArray,currentCameraRow);
        [customArray replaceObjectAtIndex:currentCameraRow withObject:tempDict];




        [pool drain];


        //NSLog(@"")
         [self startThread];        

        [picker dismissModalViewControllerAnimated:YES];
        [myCustomTableView reloadData];

        NSLog(@"size of myObject: %zd", malloc_size(myCustomTableView));

    }

Could anyone be so kind as to help with the code above ? I am guessing an if/else statement but have not the first idea of what it would be and where to place it.

Thanks in advance,

Chris

EDIT – Ok I now have it working the load from gallery now loads ‘Photos’ in a small window, where I can select, however there is no ‘Select’ or ‘Choose’ button, if I click the photo, there is no tick, to say it is selected, however it does select it, but to dismiss I click outside the window… So it works, but I am guessing I have missed something out, here is the code;

-(void) actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex{
if (buttonIndex == 0) {
    if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypePhotoLibrary]) {
        UIImagePickerController *picker = [[UIImagePickerController alloc] init];
        picker.delegate = self;
        picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;

        if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
        {
            if(popoverController != nil)
            {
                [popoverController release];
                popoverController = nil;
            }
            UIPopoverController* popover = [[UIPopoverController alloc] initWithContentViewController:picker];
            popoverController = popover;
            popoverController.delegate = self;
            [popover presentPopoverFromRect:CGRectMake(0, 0, 200, 800)
                                     inView:self.view
                   permittedArrowDirections:UIPopoverArrowDirectionAny
                                   animated:YES];
        }
        else
        {
            [self presentModalViewController:picker animated:YES];
        }



//      [self presentModalViewController:picker animated:YES];
        [picker release];
    }
    else {
        UIAlertView *alert = [[UIAlertView alloc]
                              initWithTitle:@"Error accessing photo library"
                              message:@"Device does not support a photo library"
                              delegate:nil
                              cancelButtonTitle:@"Abort!"
                              otherButtonTitles:nil];
        [alert show];
        [alert release];
     }

}
    if (buttonIndex == 1) {


    if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {
        UIImagePickerController *picker = [[UIImagePickerController alloc] init];
        picker.delegate = self;
        picker.allowsEditing = YES;
        picker.sourceType =UIImagePickerControllerSourceTypeCamera; 
        [self presentModalViewController:picker animated:YES];
        [picker release];
    }
    else {
        UIAlertView *alert = [[UIAlertView alloc]
                              initWithTitle:@"Error accessing Camera"
                              message:@"Device does not support a Camera"
                              delegate:nil
                              cancelButtonTitle:@"Abort!"
                              otherButtonTitles:nil];
        [alert show];
        [alert release];
    }

    }


}


-(void) imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info{
    NSLog(@"the info opf picker is %@",info);
    NSAutoreleasePool *pool=[[NSAutoreleasePool alloc]init];
    NSData *imageData;

    if ([info objectForKey:UIImagePickerControllerEditedImage]) {
        UIImage *image2=[info objectForKey:UIImagePickerControllerEditedImage];
        //UIImage *myscaledImage=[self scaleImage:image2 toSize:CGSizeMake(18, 24)];
        //imageData = UIImagePNGRepresentation(myscaledImage);

        imageData=UIImageJPEGRepresentation(image2, .4);
        NSLog(@"the lenght of the edited image data is %d",[imageData length]);

    }
    else {
        UIImage *image=[info objectForKey:UIImagePickerControllerOriginalImage];

        //UIImage *myscaledImage=[self scaleImage:image toSize:CGSizeMake(18, 24)];
        //imageData = UIImagePNGRepresentation(myscaledImage);

        imageData=UIImageJPEGRepresentation(image, .6);
        NSLog(@"the lenght of the image dataa is %d",[imageData length]);

    }


    NSDictionary *tempDict=[NSDictionary dictionaryWithObjectsAndKeys:imageData,@"Image",@"Theme",@"Cell_Text",nil];
//  NSLog(@"the custom array%@ and the row =%d", customArray,currentCameraRow);
    [customArray replaceObjectAtIndex:currentCameraRow withObject:tempDict];




    [pool drain];


    //NSLog(@"")
     [self startThread];        

    [picker dismissModalViewControllerAnimated:YES];
    [myCustomTableView reloadData];

    NSLog(@"size of myObject: %zd", malloc_size(myCustomTableView));



}

-(UIImage *)scaleImage:(UIImage *)image toSize:(CGSize)newSize {  
    UIGraphicsBeginImageContext(newSize);  
    [image drawInRect:CGRectMake(0, 0, newSize.width, newSize.height)];  
    UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext();  
    UIGraphicsEndImageContext();

    return newImage;  
}


- (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker
{
    [self dismissModalViewControllerAnimated:YES];
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T17:00:15+00:00Added an answer on June 15, 2026 at 5:00 pm

    The error is very clear:

    On iPad, UIImagePickerController must be presented via UIPopoverController’

    You need to put the image picker in a popover controller when run on the iPad. This is true when the sourceType is for the photo library. The camera based image picker can be shown as a full screen modal view controller.

    This isn’t an issue on the iPhone because the iPhone doesn’t support the UIPopoverController.

    The sample app PrintPhoto demonstrates how to show the image picker in a popover. Specifically, see PrintPhotoViewController.m.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am getting a crash with the following error message: [FilterPurchase respondsToSelector:]: message sent
I'm getting the following message in my users' crash logs: Dyld Error Message: Symbol
Possible Duplicate: presentViewController: crash on iOS 6 (AutoLayout) I'm getting this error when clicking
I am getting crash reports on android.widget.ListView lv; lv.removeFooterView(v) The error is null pointer
Getting a crash when trying to pass the string into NSDateFormatter dateFromString method. I
I am getting the following jvm crash every few days running Tomcat 6.0.16 on
I am getting below error that causing crash. Terminating app due to uncaught exception
I'm getting this error while working on map (Drawing line on map using GetDirection
I am getting a Fatal Error on using a ExecuteNonQuery(). I'm new to working
I am puzzled by a crash I keep getting due to an error at

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.