gpt4 book ai didi

ipad - ARC 环境下 iPad 上的 UIPopoverController 和 UIImagePickerController

转载 作者:行者123 更新时间:2023-12-03 03:28:35 27 4
gpt4 key购买 nike

我正在尝试在 iPad 上使用相机,为此我必须在 iPad 上使用 UIPopoverController。无论 UIPopoverController 声明为强,我都收到以下错误!

*** Terminating app due to uncaught exception 'NSGenericException', reason: '-[UIPopoverController dealloc] reached while popover is still visible.'

以下是我的代码。谁能告诉我我做错了什么吗?我已经解决了大多数相关问题,但大多数人都说声明 UIPopoverController 强大,我已经在这样做了!

#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

最佳答案

在这种情况下,PopoverController 拥有 ImagePicker,因此问题(可能)是您正在忽略 ImagePicker 而不是容器 PopoverController。

你打电话的地方

[选择器dismissModalViewControllerAnimated:YES];

使用

[self.popoverController DismissPopoverAnimated:YES];

无需显式关闭 ImagePicker

关于ipad - ARC 环境下 iPad 上的 UIPopoverController 和 UIImagePickerController,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11455141/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com