我在开发iPad应用时尝试访问照片库时遇到问题。但是,相同的代码适用于iPhone dev。生成的错误是:
On iPad, UIImagePickerController must be presented via UIPopoverController
我正在使用以下代码进行iPad开发:
if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypePhotoLibrary])
{
UIImagePickerController * picker = [[UIImagePickerController alloc] init];
picker.delegate = self;
picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
[self presentModalViewController:picker animated:YES];
[picker release];
}
答案 0 :(得分:0)
尝试使用iPad中的弹出控制器,不支持模态视图控制器
即使我遇到了同样的问题,所以尝试使用pop over controller并且现在可以正常工作:)
UIImagePickerController * picker = [[UIImagePickerController alloc] init];
picker.delegate = self;
picker.sourceType = UIImagePickerControllerSourceTypeSavedPhotosAlbum;
popControl = [[UIPopoverController alloc]initWithContentViewController:picker];
popControl.delegate=self;
[popControl presentPopoverFromRect:browseButton.bounds inView:mainView permittedArrowDirections:UIPopoverArrowDirectionLeft animated:YES];