views:

56

answers:

1

Below is some code I am using to display a popup. The first time this is called the popup gets displayed. The 2nd time it is called it fails with a "EXE_BAD_ACCESS" error. It fails on the line "self.myTextPopOver = pop;" If I comment out the line [pop release] everything works OK but that would mean I am leaking memory.

// Popover Text
- (IBAction)popoverText
{

// Create a popover object
setTextPopOver *setTX = [[setTextPopOver alloc] init];

// Create a UIPopover controller based on a setTextPopOver object
UIPopoverController *pop = [[UIPopoverController alloc] initWithContentViewController:setTX];

// Set self as the delegate
setTX.delegate = self;

// Set the mySelectColorView to PopOver Controller
self.myTextPopOver = pop;
[pop release];

// Present the Popover
[self.myTextPopOver presentPopoverFromRect:titleBack.frame inView:self.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:true];
[self.myTextPopOver setPopoverContentSize:setTX.view.frame.size];
[setTX release];

}
A: 

Can you show the full call stack?

If this happens when another popover is showing, you should be calling [popoverController dismissPopoverAnimated:YES]; first.

Shaggy Frog