0

i am using uiimage picker control in ipad based application.so i am displaying it using the following code:

[self presentModalViewController:myImagePicker animated:YES];

but there is a error that shows

'On iPad, UIImagePickerController must be presented via UIPopoverController'

how can i add a UIImagePickerController controller to my ipad based application to show multiple images.can any one provide me a good way to do it.

Soner Gönül
  • 97,193
  • 102
  • 206
  • 364
Vipin
  • 4,718
  • 12
  • 54
  • 81

2 Answers2

0

Do like this.When you click on a button in button action call this.

UIActionSheet *photoActionSheet = [[UIActionSheet alloc] initWithTitle:@"" delegate:self cancelButtonTitle:@"Cancel" destructiveButtonTitle:nil otherButtonTitles:@"Take Photo", @"Choose Existing",nil];

        [photoActionSheet showFromRect:CGRectMake(315, 355, 10, 10) inView:self.view animated:YES];
Tendulkar
  • 5,550
  • 2
  • 27
  • 53
0
#pragma mark UIActionSheetDelegate methods

- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex{
    imgPicker.delegate = self;


    if(buttonIndex == 0){

            if([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]){
                imgPicker.sourceType = UIImagePickerControllerSourceTypeCamera;
                [self presentModalViewController:imgPicker animated:YES];

        }


    else if(buttonIndex == 1){


            imgPicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
            [self presentModalViewController:imgPicker animated:YES];


    }

}
Tendulkar
  • 5,550
  • 2
  • 27
  • 53
  • 'NSInvalidArgumentException', reason: 'On iPad, UIImagePickerController must be presented via UIPopoverController' – Vipin Jun 09 '11 at 12:46
  • let you know my questions is "i am using uiimage picker control in ipad based application" – Vipin Jun 09 '11 at 12:49