Search code examples
iosobjective-cipaduipopovercontroller

UIPopover equal screen width


I need to make popover size Equal device screen width, is it possible? I try such code:

ShareViewController *shareVC = [[ShareViewController alloc] init];
sharePopover = [[UIPopoverController alloc] initWithContentViewController:shareVC];
sharePopover.popoverContentSize = shareVC.view.frame.size; // width there is 1024 i'm sure
sharePopover presentPopoverFromRect:CGRectMake(sender.frame.origin.x, sender.frame.origin.y + 10, sender.frame.size.width, sender.frame.size.height) inView:self.view permittedArrowDirections:UIPopoverArrowDirectionUp animated:YES];

also i tried to set width in popoverContentSize by number like 1024, or bigger, but no effect, i have some spaces in left and right, how can i fix it?

Here screenshot of problem: http://uaimage.com/image/c54d471d


Solution

  • From Apple's UIPopoverController documentation, regarding the 'popoverLayoutMargins' property (can be found here: UIPopoverController documentation:

    The margins that define the portion of the screen in which  
    it is permissible to display the popover....
    ...The edge inset values are measured in points from the edges of the screen,  
    relative to the current device orientation...  
    ...The default edge insets are 10 points along each edge.  
    

    Try adding the following and see if it helps:

    sharePopover.popoverLayoutMargins = UIEdgeInsetsZero;