presentPopoverFromRect在iOS8 beta中不显示popover [英] presentPopoverFromRect not displaying popover in iOS8 beta
问题描述
我正在将iOS7.1 iPad应用程序迁移到iOS8。我刚刚下载了Xcode 6 Beta,并在模拟器上运行了该应用程序。我注意到的第一件事是在iOS7.1中运行良好的弹出窗口不再起作用了。我创建popover的方式是:
I am migrating an iOS7.1 iPad app to iOS8. I just downloaded Xcode 6 Beta, and ran the application on a simulator. First thing I notice is the popovers which worked fine in iOS7.1 don't work anymore. The way I an creating the popover is:
// the popover controller
UIPopoverController *popOverController;
// the content to be shown in the popover
DropdownViewController dropdownVC = [self.navigationController.storyboard instantiateViewControllerWithIdentifier:@"DropdownViewController"];
// initialize popover
popOverController = [[UIPopoverController alloc] initWithContentViewController:dropdownVC];
// set delegate
dropdownPopOverController.delegate = self;
// set content size
[popOverController setPopoverContentSize:CGSizeMake(SIZE_POPOVER_WIDTH, SIZE_POPOVER_HEIGHT)];
// set the frame
CGRect frame = button.frame; // determine frame
// present popover
[popOverController presentPopoverFromRect:frame
inView:self.view
permittedArrowDirections:UIPopoverArrowDirectionLeft
animated:YES];
有没有人遇到过类似的问题?是否必须在iOS8中以其他方式显示popovers。感谢您的投入。
Has anyone faced a similar issue? Do popovers have to be displayed in another way in iOS8. Thanks for your inputs.
推荐答案
所以我想出了如何在iOS8中显示popover:
So I figured out how to show the popover in iOS8:
在iOS7.1中,我使用
In iOS7.1, I was controlling the size of the popover content using
// set content size
[popOverController setPopoverContentSize:CGSizeMake(SIZE_POPOVER_WIDTH, SIZE_POPOVER_HEIGHT)];
在iOS8中,我将此更改为设置弹出视图中嵌入的视图的内容大小setPreferredContentSize属性如下:
In iOS8, I changed this to setting the content size of the view embedded in the popover view using the setPreferredContentSize property as follows:
dropdownVC.preferredContentSize = CGSizeMake(SIZE_POPOVER_WIDTH, SIZE_POPOVER_HEIGHT);
进行此更改后,将显示具有正确计算高度的弹出窗口。
After making this change, the popover with the correct calculated height is being displayed.
这篇关于presentPopoverFromRect在iOS8 beta中不显示popover的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!