1

我正在使用UIImagePickerController用于选择图像并在 ipad 应用程序中使用图像它在模拟器上工作正常但它没有imagepickerController在设备中打开这是我的代码

        else if([labelType.text isEqualToString:@"Select Image"]){

        selectedType=@"Select Image";

        BOOL isiPhone;

        UIImagePickerController *pckrImage = [[UIImagePickerController alloc] init];
        pckrImage.delegate = self;
        if (isiPhone) {
            if ([UIImagePickerController isSourceTypeAvailable: UIImagePickerControllerSourceTypePhotoLibrary]) 
            {
                pckrImage.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;                  
                [self presentModalViewController:pckrImage animated:YES];
            }
            else {

            }
        }
        else
        {
            popOver = [[UIPopoverController alloc]initWithContentViewController:pckrImage];
            [popOver presentPopoverFromRect:CGRectMake(450.0f, 825.0f, 10.0f, 10.0f) inView:self.view permittedArrowDirections:UIPopoverArrowDirectionDown animated:YES];       
        }    
}
4

3 回答 3

0

Please make change as

UIImagePickerController *pckrImage = [[UIImagePickerController alloc] init];
        pckrImage.delegate = self;
        if (isiPhone) {
            if ([UIImagePickerController isSourceTypeAvailable: UIImagePickerControllerSourceTypePhotoLibrary])



            {
                pckrImage.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;







                [self presentModalViewController:pckrImage animated:YES];
            }
            else {

            }
        }
        else
        {
            UIPopoverController *popOver = [[UIPopoverController alloc]initWithContentViewController:pckrImage];
            self.popoverImageViewController = popOver;
            [self.popoverImageViewController presentPopoverFromRect:CGRectMake(450.0f, 825.0f, 10.0f, 10.0f) inView:self.view permittedArrowDirections:UIPopoverArrowDirectionDown animated:YES];


        }   

Initialize the object

@property (strong,nonatomic) UIPopoverController *popoverImageViewController;
于 2013-09-12T07:34:38.380 回答
0

尝试使用 UIPopoverArrowDirectionAny 呈现弹出框。

[self.popoverController presentPopoverFromRect:CGRectMake(450.0f, 825.0f, 10.0f, 10.0f)
                                                            inView:self.view
                                          permittedArrowDirections:UIPopoverArrowDirectionAny
                                                          animated:YES];
于 2014-03-13T10:49:31.937 回答
0

尝试这个:

UIImagePickerController *pckrImage = [[UIImagePickerController alloc] init];
    pckrImage.delegate = self;
if ([UIImagePickerController isSourceTypeAvailable: UIImagePickerControllerSourceTypePhotoLibrary]) {
            pckrImage.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;

    if (isiPhone) {

            [self presentModalViewController:pckrImage animated:YES];

    }
    else
    {
        popOver = [[UIPopoverController alloc]initWithContentViewController:pckrImage];
        [popOver presentPopoverFromRect:CGRectMake(450.0f, 825.0f, 10.0f, 10.0f) inView:self.view permittedArrowDirections:UIPopoverArrowDirectionDown animated:YES];       
    }
}

希望这可以帮助。

于 2013-09-12T07:52:59.097 回答