0

我试图让我的 imagePicker 从我的 sourceLibrary 加载照片。使用以下代码,应用程序崩溃并显示以下消息“应用程序试图以模态方式呈现活动控制器”

-(void)viewPhotoLibrary{
NSLog(@"get photos");



UIImagePickerController  *imagePickerController =
[[UIImagePickerController alloc] init];


    UIPopoverController  *pop = [[UIPopoverController alloc]
                                   initWithContentViewController:imagePickerController];
    pop.delegate = self;
    [pop setPopoverContentSize:CGSizeMake(500, 500)];



    [pop presentPopoverFromRect:
     CGRectMake(0, 0, 500, 500)
                           inView:self.view
         permittedArrowDirections:UIPopoverArrowDirectionAny
                        animated:YES];






    [imagePickerController setSourceType:UIImagePickerControllerSourceTypePhotoLibrary];
    [imagePickerController setDelegate:self];
    [imagePickerController setModalPresentationStyle:UIModalPresentationFullScreen];
    [self presentViewController:imagePickerController animated:YES completion:nil];


}
4

1 回答 1

2

注释代码

[imagePickerController setSourceType:UIImagePickerControllerSourceTypePhotoLibrary];
[imagePickerController setDelegate:(id)self];
[imagePickerController setModalPresentationStyle:UIModalPresentationFullScreen];
[self presentViewController:imagePickerController animated:YES completion:^{

}];

或使用此代码

-(void)viewPhotoLibrary{
NSLog(@"get photos");

 UIImagePickerController  *imagePickerController =
[[UIImagePickerController alloc] init];


  UIPopoverController  *pop = [[UIPopoverController alloc]
                               initWithContentViewController:imagePickerController];
  pop.delegate = self;
  [pop setPopoverContentSize:CGSizeMake(500, 500)];



  [pop presentPopoverFromRect:
   CGRectMake(0, 0, 500, 500)
                       inView:self.view
       permittedArrowDirections:UIPopoverArrowDirectionAny
                    animated:YES];

      }
于 2013-06-11T10:47:26.673 回答