gpt4 book ai didi

ios - UIPopoverController 在运行 iOS 5.0.1 的 iPad 上崩溃?

转载 作者:行者123 更新时间:2023-11-28 23:10:09 26 4
gpt4 key购买 nike

我在 iPad 上使用 iOS 5 上的 UIImagePickerController,我的应用程序刚刚被拒绝,因为它在他们那端崩溃了。它不会在我这边崩溃,但我确信它与 UIPopoverController 有关。

请指出任何看起来不好的地方!

显示 UIImagePickerController:

- (IBAction)photoLibraryiPad {
if (popoverController) {
if ([self.popoverController isPopoverVisible]) {
[self.popoverController dismissPopoverAnimated:YES];
[popoverController setDelegate:nil];
[popoverController release];
}
} else {
if ([UIImagePickerController isSourceTypeAvailable:
UIImagePickerControllerSourceTypeSavedPhotosAlbum])
{
UIImagePickerController *imagePicker =
[[UIImagePickerController alloc] init];
imagePicker.delegate = self;
imagePicker.sourceType =
UIImagePickerControllerSourceTypePhotoLibrary;
imagePicker.allowsEditing = YES;

self.popoverController = [[UIPopoverController alloc]
initWithContentViewController:imagePicker];

popoverController.delegate = self;

[self.popoverController presentPopoverFromRect:photolibrarybutton.frame inView:self.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];

[imagePicker release];
}
}

然后这就是他们崩溃的地方:

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {

if ([self.popoverController isPopoverVisible]) {
[self.popoverController dismissPopoverAnimated:YES];
[popoverController setDelegate:nil];
[popoverController release];
}

[noimageAvailable setHidden:YES];
UIImage *originalImage = (UIImage *) [info objectForKey:
UIImagePickerControllerEditedImage];
[imgPic setImage:originalImage forState:UIControlStateNormal];
// Hide picker selector
[picker dismissModalViewControllerAnimated: YES];
[picker release];

}

最佳答案

两件事:

1) 当你释放popover时,你应该将delegate设置为nil。 popoverController.delegate = nil 在调用 [popoverController release] 之前。如果您尝试多次使用选择器,它很可能也会为您崩溃。委托(delegate)正在调用一个不再存在的对象。

2) 检查弹出窗口是否可见时,首先检查以确保它存在。

关于ios - UIPopoverController 在运行 iOS 5.0.1 的 iPad 上崩溃?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8483518/

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