我正在尝试在 iPad 上使用相机,为此我必须在 iPad 上使用 UIPopoverController。无论 UIPopoverController 声明是否强大,我都会遇到以下错误!
*** Terminating app due to uncaught exception 'NSGenericException', reason: '-[UIPopoverController dealloc] reached while popover is still visible.'
以下是我的代码。谁能告诉我我做错了什么?我已经解决了关于 SO 的大多数相关问题,但其中大多数都说声明 UIPopoverController strong 我已经在做!
#import "ImagePickerController.h"
@interface ImagePickerController()
@property(nonatomic, strong) UIPopoverController *popoverController;
@end
@implementation ImagePickerController
@synthesize imageName;
@synthesize popoverController;
- (void)didReceiveMemoryWarning
{
// Releases the view if it doesn't have a superview.
[super didReceiveMemoryWarning];
}
- (void)viewDidUnload
{
[super viewDidUnload];
}
#pragma mark - UIImagePickerController Delegate
-(void) captureImageFromCamera:(UIViewController*)view
{
UIImagePickerController *imagePickerController = [[UIImagePickerController alloc] init];
imagePickerController.delegate = self;
self.popoverController = [[UIPopoverController alloc] initWithContentViewController:imagePickerController];
self.popoverController.delegate = self;
[self.popoverController presentPopoverFromRect:view.view.bounds inView:view.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
}
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
[picker dismissModalViewControllerAnimated:YES];
}
- (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker
{
[picker dismissModalViewControllerAnimated:YES];
}
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)image editingInfo:(NSDictionary *)editingInfo
{
[picker dismissModalViewControllerAnimated:YES];
}
#pragma mark - UIPopoverController Delegate
- (void)popoverControllerDidDismissPopover:(UIPopoverController *)popoverController
{
}
- (BOOL)popoverControllerShouldDismissPopover:(UIPopoverController *)popoverController
{
return YES;
}
@end