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

发布于 2024-12-21 06:15:26 字数 1968 浏览 6 评论 0原文

我在 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];

}

I am using a UIImagePickerController on iOS 5 with the iPad and my app just got rejected because it crashed on their end. It doesn't crash on my end but I am sure it has to do with the UIPopoverController.

Please just point anything out that looks bad!

To show the 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];
    }
}

}

Then this is where it is crashing on their end:

- (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];

}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

花落人断肠 2024-12-28 06:15:26

两件事:

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

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

Two things:

1) When you release the popover, you should set the delegate to nil. popoverController.delegate = nil before calling [popoverController release]. Chances are if you try to use the picker multiple times, it will crash for you too. The delegate is calling an object that no longer exists.

2) When checking to see if the popover is visible, check to make sure it exists first.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文