0

我尝试使用以下代码在 UIPopoverController 上调整 UIImagePickerController 的大小:

 UIImagePickerController *imagePicker =[[UIImagePickerController alloc] init];
            imagePicker.delegate = self;
            imagePicker.sourceType =
            UIImagePickerControllerSourceTypePhotoLibrary;
            imagePicker.mediaTypes = [NSArray arrayWithObjects:
                                      (NSString *) kUTTypeImage,
                                      nil];
            imagePicker.allowsEditing = YES;
           UIViewController *containerController = [[UIViewController alloc] init];
            containerController.contentSizeForViewInPopover = CGSizeMake(360,200);
           [containerController.view addSubview:imagePicker.view];
            self.popoverController = [[UIPopoverController alloc]
                                      initWithContentViewController:imagePicker];

             self.popoverController.delegate = self;
            [self.popoverController setPopoverBackgroundViewClass:[PopoverBackgroundView class]];

     [self.popoverController presentPopoverFromRect:CGRectMake(512,510,10,10) inView:mC.view permittedArrowDirections:UIPopoverArrowDirectionDown animated:FALSE];
            }

imagePicker 完全按照我的意愿填充,但是当我触摸 popover 内的 imagePicker 的单元格时,它突然熄灭或变空。

4

1 回答 1

0

如果您想在 UIPopoverController 将/确实被解雇时访问 UIImagePickerController ,请使用 UIPopoverControllerDelegate 方法:

- (BOOL)popoverControllerShouldDismissPopover:(UIPopoverController *)popoverController{
    UIImagePickerController *imagePicker = (UIImagePickerController*)popoverController.contentViewController;
    return YES;
}

可以帮助你:)

于 2012-11-23T14:29:21.340 回答