开发者

UIPopoverController deallocated issue

I used a Popover to display image in it. When the user touch a button, the popover appears with a slideshow inside.

I initialize the Popover like this : `

- (IBAction)showPopover:(UIButton *)sender {
    myPopover *content = [[myPopover alloc] init];
    detailViewPopover = [[UIPopoverController alloc] initWithContentViewController:content];
    detailViewPopover.popoverContentSize = CGSizeMake(600., 400.);
    detailViewPopover.delegate = self;

    [detailViewPopover presentPopoverFromRect:sender.frame inView:self.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];

    [content release];
}

` detailViewPopover is a UIPopoverController, 开发者_运维百科I declare it my .h.

I dismiss the Popover like this : `

- (void)popoverControllerDidDismissPopover:(UIPopoverController *)popoverController {
    // If a popover is dismissed, set the last button tapped to nil.
    [popoverController release];

}`

When I run my app, it works until I got "-[UIPopoverController release]: message sent to deallocated instance 0x1b29b0" and my apps crashes... I understand I release too much time my UIPopoverController, but I don't know where. Is my implementation good ?

Thanks for your help

Let me know if you need more information, I will edit the post


You shouldn't release your popoverController here.

You need to call release on detailViewPopover in your current view controllers dealloc method

- (void) dealloc
{
    [detailViewPopover release];
    [super dealloc];
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜