Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

presentPopoverFromRect not displaying popover in iOS8 beta

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.

like image 720
Marym Matthews Avatar asked Feb 12 '23 02:02

Marym Matthews


1 Answers

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.

like image 153
Marym Matthews Avatar answered Feb 15 '23 09:02

Marym Matthews