UIPopoverController上的UIImagePicker在点击或触摸时熄灭

时间:2012-11-23 13:50:50

标签: iphone objective-c ios ipad

我尝试使用以下代码在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的单元格时,它会突然变为空或变空。

1 个答案:

答案 0 :(得分:0)

如果你想在UIPopoverController被解雇时访问UIImagePickerController,请使用UIPopoverControllerDelegate方法:

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

可以帮助你:)