How to center a UIPopoverController and also without arrows

Short recipe here. This blog isn’t always about you… it’s about augmenting my memory! 😀

  UIViewController *contentController = [[UIViewController alloc] init]; // obviously your own...
  UIPopoverArrowDirection arrows;
  CGRect rectForWindow;
  BOOL centeredInWindow = YES;
  if (centeredInWindow) {
    rectForWindow = CGRectMake(self.view.bounds.size.width/2, self.view.bounds.size.height/2, 1, 1);
    arrows = 0;
    // view being some view like a UIButton, that triggered the popup...
    rectForWindow = [self.view convertRect:view.frame fromView: view.superview];  // or whatever...
    arrows = UIPopoverArrowDirectionDown;  // or whatever...

  self.popover = [[UIPopoverController alloc] initWithContentViewController:contentController];
  self.popover.delegate = self;
  // set your contentSize
  CGSize contentSize = (CGSize){320, 460};
  [self.popover setPopoverContentSize:contentSize];
  [self.popover presentPopoverFromRect:rectForWindow 

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s