UIPopover屏幕宽度相等

时间:2014-10-25 12:21:32

标签: ios objective-c ipad uipopovercontroller

我需要使popover大小等于设备屏幕宽度,是否可能?我尝试这样的代码:

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

我还尝试将popoverContentSize中的宽度设置为1024或更大的数字,但没有效果,我左右有一些空格,我该如何解决?

这里的问题截图: http://uaimage.com/image/c54d471d

1 个答案:

答案 0 :(得分:0)

从Apple的UIPopoverController文档中,关于'popoverLayoutMargins'属性(可在此处找到: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.  

尝试添加以下内容,看看是否有帮助:

sharePopover.popoverLayoutMargins = UIEdgeInsetsZero;