无法居中 UIPopoverController
Unable to center UIPopoverController
在我的应用程序中,我试图将 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];
它总是在左下角显示弹出窗口...
这段代码有什么问题?
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(self.view.bounds.size.width/2, self.view.bounds.size.height/2, 1, 1);
[aPopover presentPopoverFromRect:rect inView:self.view permittedArrowDirections:0 animated:YES];
在我的应用程序中,我试图将 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];
它总是在左下角显示弹出窗口... 这段代码有什么问题?
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(self.view.bounds.size.width/2, self.view.bounds.size.height/2, 1, 1);
[aPopover presentPopoverFromRect:rect inView:self.view permittedArrowDirections:0 animated:YES];