我正在开发一个iPad应用程序,我有一个生成弹出控制器的按钮,我用特定的视图控制器填充。这是生成UIPopoverController并使用特定视图加载它的按钮代码(signUpListAddEditViewController):
-(void)addSignUpList:(id)sender {
signUpListAddEditViewController = [[SignUpListAddEditViewController alloc] init];
popover = [[UIPopoverController alloc] initWithContentViewController:signUpListAddEditViewController];
popover.popoverContentSize = signUpListAddEditViewController.view.frame.size;
[popover presentPopoverFromBarButtonItem:sender permittedArrowDirections:UIPopoverArrowDirectionUp animated:YES];
signUpListAddEditViewController.popover = popover;
}
在SignUpListAddEditViewController.m中,我有几个字段和一个tableview。其中一个字段是UIButton,我在其中显示图像并允许用户使用此按钮加载新图像。由于我已经在popover中,我将内容控制器与UIImagePickerController交换。到目前为止,非常好。
-(void)takePicture:(id)sender
{
UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];
[imagePicker setSourceType:UIImagePickerControllerSourceTypePhotoLibrary];
[popover setPopoverContentSize:popupScreenSize animated:YES]; // popupScreenSize is a CGSIZE set to 500 x 900
[popover setContentViewController:imagePicker animated:YES];
}
视图与imagePicker交换,其大小与原始视图相同,我可以看到各种图片库(相机胶卷,照片流等)。这是奇怪的地方。当我选择其中一个图库时,视图将替换为该图库中图片的缩略图视图,然后视图将调整为更窄的宽度。图像失真,几乎不可能选择其中一个。
在每次访问弹出控制器之前,我尝试过设置[popover setPopoverContentSize:CGSIZE animated:YES],除了详细的图像视图外,所有内容都正确调整大小?我可以覆盖缩略图库视图的任何想法吗?
这是didFinishPickingMediaWithInfo方法的代码,我再次覆盖内容大小:
-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
UIImage *image = [info objectForKey:UIImagePickerControllerOriginalImage];
[thisList setThumbnailDataFromImage:image];
[popover setPopoverContentSize:popupScreenSize animated:YES];
[popover setContentViewController:self animated:YES];
listImageButton.imageView.image = image;
}