我目前正在为 iPad 开发一个 iPad 应用程序,我将 UIPopOverController 与 UIImagePickerController 结合使用,让用户从他们的 iPad 中选择图像(使用 sourceType UIImagePickerControllerSourceTypeSavedPhotosAlbum)。这工作得很好,正如预期的那样,但它只允许客户端显然浏览 SavedPhotos 相册。如果我将选择器更改为使用 UIImagePickerControllerSourceTypePhotoLibrary,窗口仍将显示其相册,但它将是静态的(意味着我可以滚动,但我无法选择相册,并且当我向下或向上滚动时,视图只会弹出如果我再次点击屏幕返回)。
PhotoLibrary 是否需要额外的设置才能正常工作?我尝试了很多方法,但我在这里都不走运。
设置是一个 OpenGL 视图,我在其上使用 UIImagePicker 生成 UIPopOverController。为了清楚起见,这里是代码:
-(void)showPicker
{
if(![pController isPopoverVisible])
{
[pController presentPopoverFromRect:CGRectMake(50,100,200,300) inView:self.view permittedArrowDirections:UIPopoverArrowDirectionLeft animated:YES];
}
else
{
pController dismissPopoverAnimated:YES];
}
}
-(void)awakeFromNib
{
picker = [[UIImagePickerController alloc] init];
pController = [[UIPopoverController alloc] initWithContentViewController:picker];
// Code works properly if I only set it to UIImagePickerControllerSourceTypeSavedPhotosAlbum
if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypePhotoLibrary]) picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
else if([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeSavedPhotosAlbum]) picker.sourceType =UIImagePickerControllerSourceTypeSavedPhotosAlbum;
else { NSLog(@"Error: Could not pick appropriate sourceType"); }
picker.mediaTypes = [NSArray arrayWithObjects:(NSString*)kUTTypeImage, nil];
picker.delegate = self;
pController.delegate = self;
picker.allowsEditing=NO;
}