UIImagePickerControllerを使用して、iPhone/iPadでユーザーの写真から写真を取得しようとしています。このコードはiPhoneでうまく動作しますが、iPadで実行すると、デバッガは "キャッチされていない例外 'NSGenericException'の理由でアプリを終了しています。理由: ' - [UIPopoverController dealloc]私はObjective-Cをとても新しくしているので、これを引き起こしていることが分かりません。何も解除しないで、ARCをオンにしました。ここに私のコードは次のとおりです。 ViewController.mUIPopoverControllerで奇妙なエラーが発生する
#import "PhotoViewController.h"
@implementation PhotoViewController
@synthesize grabButton;
@synthesize image;
@synthesize imgPicker;
- (IBAction)grabImage {
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) {
UIPopoverController *popover = [[UIPopoverController alloc] initWithContentViewController:imgPicker];
[popover presentPopoverFromRect:self.image.bounds inView:self.image permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
} else {
[self presentModalViewController:imgPicker animated:YES];
}
}
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)img editingInfo:(NSDictionary *)editInfo {
image.image = img;
[[picker parentViewController] dismissModalViewControllerAnimated:YES];
}
- (void)viewDidLoad
{
self.imgPicker = [[UIImagePickerController alloc] init];
self.imgPicker.allowsImageEditing = YES;
self.imgPicker.delegate = self;
self.imgPicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
[super viewDidLoad];
// Do any additional setup after loading the view from its nib.
}
可能なデュープます。http :/ /stackoverflow.com/questions/8895071/uipopovercontroller-dealloc-reached-while-popover-is-still-visible – CodaFi
投稿前にそれを見ましたが、残念ながら助けにはなりませんでした。 –