【发布时间】:2014-12-21 03:22:59
【问题描述】:
我需要使弹出框大小等于设备屏幕宽度,可以吗?我试试这样的代码:
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
【问题讨论】:
-
如果您想要这种完全控制,请考虑使用弹出框以外的其他东西。为什么不是呈现的视图控制器?在 iOS 7 和 8 中,很容易让呈现的视图出现在主视图的前面,就像弹出框一样。你所拥有的甚至看起来都不像一个弹出框,所以你根本不清楚为什么要使用它。
-
@matt 在我的情况下使用 popover 更舒服,因为我不需要编写动画来显示和隐藏他,但这不是主要问题,总而言之我决定使用 popover,如果没有解决方案,我会使用 UIView 或 UIViewController,谢谢。
标签: ios objective-c ipad uipopovercontroller