AddCategoryViewController* content = [[AddCategoryViewController alloc] init];
UIPopoverController* aPopover = [[UIPopoverController alloc]< br /> initWithContentViewController:content];
aPopover.delegate = self;
[content release];
// Store the popover in a custom property for later use.
self.addCategoryPopover = aPopover;
[aPopover release];
[addCategoryPopover presentPopoverFromBarButtonItem:sender permittedArrowDirections:UIPopoverArrowDirectionUp animated:YES];
In addcategoryviewcontroller, I have: p>
-(IBAction)saveAddCategory:(id)sender {
if (rootViewController == nil)
rootViewController = [[RootViewController alloc] init];
[rootViewController.addCategoryPopover dismissPopoverAnimated:YES];
[rootViewController dismissPopover];
}
Rootvie wcontroller is where the popover is created. Unfortunately, none of these methods solve it. Any help?
aPopover.delegate = self;
If you want to execute your code. The application will crash. Instead, you need to be like this.
So I have a popover with a button. When the button is pressed, I want the popup to disappear. It seems easy, but I can’t figure out my life. I use to display the popover The code is as follows:
AddCategoryViewController* content = [[AddCategoryViewController alloc] init];
UIPopoverController* aPopover = [[UIPopoverController alloc]
initWithContentViewController:content];
aPopover.delegate = self;
[content release];
// Store the popover in a custom property for later use.
self .addCategoryPopover = aPopover;
[aPopover release];
[addCategoryPopover presentPopoverFromBarButtonItem:sender permittedArrowDirections:UIPopoverArrowDirectionUp animated:YES];
In addcategoryviewcontroller, I have:
< p>
-(IBAction)saveAddCategory:(id)sender {
if (rootViewController == nil)
rootViewController = [[RootViewController a lloc] init];
[rootViewController.addCategoryPopover dismissPopoverAnimated:YES];
[rootViewController dismissPopover];
}
Rootviewcontroller is where popovers are created. Unfortunately, none of these methods solve it. Any help?
You will see a warning on this line.
aPopover.delegate = self;
If you want to execute your code. The application will crash. Instead, you need to be like this.