【发布时间】:2016-04-09 05:15:47
【问题描述】:
在我的应用程序中,我试图将 UIPopoverController 居中(我必须使用它,因为我的应用程序与 iOS 7 兼容)。我试图将其居中但没有成功。我的居中代码如下:
SummaryViewController *summaryViewController = [[SummaryViewController alloc] init];
summaryViewController.delegate = self;
aPopover = [[UIPopoverController alloc] initWithContentViewController:summaryViewController];
aPopover.popoverContentSize = CGSizeMake(summaryViewController.view.frame.size.width, summaryViewController.view.frame.size.height);
CGFloat width = [[UIScreen mainScreen] bounds].size.width;
CGFloat height = [[UIScreen mainScreen] bounds].size.height;
CGFloat popoverWidth = summaryViewController.view.frame.size.width;
CGFloat popoverHeight = summaryViewController.view.frame.size.height;
CGRect rect = CGRectMake((width - popoverWidth) / 2.0, (height -popoverHeight) / 2.0, 1, 1);
[aPopover presentPopoverFromRect:rect inView:self.view permittedArrowDirections:0 animated:YES];
它总是向我显示左角的弹出框... 这段代码有什么问题?
【问题讨论】:
-
仅供参考,
rectinpresentPopoverFromRect- 视图中用于锚定弹出窗口的矩形。
标签: ios ipad uipopovercontroller