I think I've spent 3 days trying various people's online solutions to make a popover appear and work and literally not a single example has worked.
But here is my current code. Can someone tell me why my popover is not appearing? Thanks.
popper = [[Popper alloc] initWithNibName: @"Popper" bundle: nil];
navigationController = [[UINavigationController alloc] initWithRootViewController: popper];
[navigationController presentModalViewController: popper开发者_开发问答 animated:YES];
[navigationController release];
[popper release];
Notes:
- My Popper class inherits from UIViewController.
- I have set my Xib's class to Popper in IB.
- I have set my main view controller to use UIPopoverControllerDelegate.
So have you added the navigationController to your view?
why not do:
[self presentModalViewController: popper animated:YES];
When you already initialise the navigation controller with a view all you need to do is add the navigation controller to your view.
[self.view addSubView: navigationController.view];
Dont present it as modal.
UIPopoverController
is only available on the iPad, and since you've tagged your question with iPhone
I'm assuming this may well be the issue.
For custom popovers, I recommend WEPopover
http://iosdevelopertips.com/open-source/ios-open-source-popover-api-for-iphone-wepopover.html
Just attach the view controller to the wepopovercontroller and you are done.
WEPopoverController *popOver = [[WEPopoverController alloc] initWithContentViewController:saveViewController];
[popOver presentPopoverFromBarButtonItem:sender permittedArrowDirections:UIPopoverArrowDirectionUp animated:YES];
[saveViewControlle release];
精彩评论