I have a ViewController
that when the right barButton
is pressed, a popover view shows. The popover view is a table view controller,
The problem is that when the popover shows, it just shows a view (not a table view).
But when the popover is dismissed, you can see that it flips to a tableview really quickly before it disappears.
Update: Added popController.sourceView = sender;
at the end here per @sticker:
- (IBAction)pressedButton:(id)sender {
NSLog(@"Pressed Button");
// grab the view controller we want to show
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
UIViewController *controller = [storyboard instantiateViewControllerWithIdentifier:@"Pop"];
// present the controller
// on iPad, this will be a Popover
// on iPhone, this will be an action sheet
controller.modalPresentationStyle = UIModalPresentationPopover;
[self presentViewController:controller animated:YES completion:nil];
// configure the Popover presentation controller
UIPopoverPresentationController *popController = [controller popoverPresentationController];
popController.permittedArrowDirections = UIPopoverArrowDirectionAny;
popController.barButtonItem = self.barbutton;
popController.delegate = self;
// Added per @sticker
popController.sourceView = sender;
}
Also made sure PopTableViewController
had <UITableViewDelegate, UITableViewDataSource>
for sure.
I'm still getting no tableview showing until the popover gets dismissed:
(below is what happens as soon as popover is dismissed and animating away)
I just try this one and it work fine Hope it help you
self.tbVC.modalPresentationStyle = UIModalPresentationPopover;
UIPopoverPresentationController *popOverVC = [self.tbVC popoverPresentationController];
popOverVC.barButtonItem = sender;
popOverVC.permittedArrowDirections = UIPopoverArrowDirectionAny;
[self presentViewController:_tbVC animated:YES completion:nil];