presentPopoverFromRect not displaying popover in iOS8 beta

让人想犯罪 __ 提交于 2019-12-10 17:32:37

问题


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

Has anyone faced a similar issue? Do popovers have to be displayed in another way in iOS8. Thanks for your inputs.


回答1:


So I figured out how to show the popover in iOS8:

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

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.



来源:https://stackoverflow.com/questions/25729019/presentpopoverfromrect-not-displaying-popover-in-ios8-beta

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!