0

iPadでカメラを使用しようとしていますが、これにはiPadで UIPopoverController を使用する必要があります。UIPopoverController が強いと宣言されていても、次のエラーが発生しています。

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

以下は私のコードです。誰が私が間違っているのか教えてください。私はSOに関するほとんどの関連する質問を経験しましたが、それらのほとんどは、私がすでに行っている 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
4

3 に答える 3

1

この場合、PopoverController は ImagePicker を所有しているため、問題は (おそらく) コンテナの PopoverController ではなく ImagePicker を却下していることです。

どこに電話するか

[picker dismissModalViewControllerAnimated:YES];

使用する

[self.popoverController dismissPopoverAnimated:YES];

ImagePicker を明示的に閉じる必要はありません

于 2012-07-12T15:59:24.470 に答える
0

追加してみる@property(nonatomic, strong) UIImagePickerController *imagePickerController;

合成する @synthesize imagePickerController;

imagePickerControllerメソッドを次のcaptureImageFromCameraように変更します。

imagePickerController = [[UIImagePickerController alloc] init];
于 2012-07-12T15:34:15.030 に答える
0

問題を解決できませんでしたが、これは iOS 5 でも魅力的に機能しました。http://www.techotopia.comに感謝!

于 2012-07-12T15:55:30.907 に答える