1
ここにnoobの質問があります。UIImagePickerControllerとUIPopoverControllerで2つのメモリリークが発生する
私は、次のコードを持っている:
- (IBAction)selectExistingPicture
{
if ([UIImagePickerController isSourceTypeAvailable: UIImagePickerControllerSourceTypePhotoLibrary])
{
UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];
imagePicker.delegate = self;
imagePicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
UIPopoverController *popVC = [[UIPopoverController alloc] initWithContentViewController: imagePicker];
popVC.delegate = self;
[popVC setPopoverContentSize:CGSizeMake(320, 100)];
[popVC presentPopoverFromRect:CGRectMake(39, 356, 320, 100) inView:self.view permittedArrowDirections:1 animated:NO];
}
else
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Error accessing photo library"
message:@"Device does not support a photo library" delegate:nil
cancelButtonTitle:@"Cancel" otherButtonTitles:nil];
[alert show];
[alert release];
}
}
をコンパイラは二つの潜在的なメモリリークについて私に警告します。 1つはimagePicker用、もう1つはpopVC用です。変更が必要な理由とその理由を説明してください。私は本当になぜこれが起こっているのか理解したいので、将来それを避けることができます。
ありがとうございました!
ありがとうございます!わかった。私はimagePickerへの自動リリースと警告を追加しましたが、popVCのメソッドでは手動でコードをリリースしていました(自動リリースしていてアプリがクラッシュしていたためです) – TrekOnTV2017