SRMR SRMR - 11 months ago 61
iOS Question

Popover Controller doesn't show view correctly

I have a

that when the right
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).

enter image description here
But when the popover is dismissed, you can see that it flips to a tableview really quickly before it disappears.

enter image description here
Why would this be?

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
<UITableViewDelegate, UITableViewDataSource>
for sure.

I'm still getting no tableview showing until the popover gets dismissed:

enter image description here

(below is what happens as soon as popover is dismissed and animating away)

enter image description here


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];