如何将UIImagePickerController控制器添加到基于ipad的应用程序以显示多个图像?

时间:2011-06-09 11:13:06

标签: objective-c xcode ipad uiimagepickercontroller

我在基于ipad的应用程序中使用uiimage选择器控件。所以我使用以下代码显示它:

[self presentModalViewController:myImagePicker animated:YES];

但是显示错误

'On iPad, UIImagePickerController must be presented via UIPopoverController'

如何在我的基于ipad的应用程序中添加UIImagePickerController控制器以显示多个images.can任何一个为我提供了一个很好的方法。

2 个答案:

答案 0 :(得分:0)

这样做。当您点击按钮操作中的按钮时,请调用此方法。

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];

答案 1 :(得分: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];


    }

}