Reputation: 1204
I am trying to display my popover menu whenever the user clicks on a button.
I have two methods, the first creates the button
- (void)viewDidLoad {
[super viewDidLoad];
UIBarButtonItem *btnMenu = [[UIBarButtonItem alloc]initWithTitle:@"Forms List" style:UIBarButtonItemStyleBordered target:self action:@selector(showPopover:)];
self.navigationItem.leftBarButtonItem = btnMenu;
}
And the second is called by the first, to display the popover
-(IBAction)showPopover:(id)sender{
NSLog(@"called with %@", sender);
self.popoverController = popoverController;
popoverController.delegate = self;
[popoverController presentPopoverFromBarButtonItem:sender permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
}
Presently, when I click the button nothing happens. I think the problem lies in the second method, mainly the presentPopoverFromBarButtonItem
line.
Any help would be appreciated, I don't really understand how that method call works.
Thanks.
EDIT 1:
Here is the code where I (think) initialize the popoverController
@interface DetailViewController ()
@property (nonatomic, retain) UIPopoverController *popoverController;
- (void)configureView;
@end
@implementation DetailViewController
@synthesize toolbar, popoverController, detailItem, detailDescriptionLabel;
Upvotes: 0
Views: 3278
Reputation: 1727
Have you initialized your UIPopoverController
?
UIPopoverController *popoverController = [[UIPopoverController alloc] initWithContentViewController:VCTHATGOESINSIDE];
If all else fails, try presenting it from rect and specify a CGRect
. Hope this helps!
edit: initWith*Content*ViewController
Upvotes: 1