UIPopoverPresentationController/UIPopoverController loses backgroundColor on interface rotation

2.3k views Asked by At

I've got a menu in iOS that I'm displaying in a popover. I can present a popover in both iOS7 and iOs8 using UIPopoverController and UIPopoverPresentation controllers respectively. I'm running into a problem though that when the popover is visible and the device rotates, the popover disappears for a split second during the animation, then it reappears after the animation. The problem is, when the popover reappears, its background color is drawn as the default background color.

I'm setting the color by using the backgroundColor property.

self.popoverPresentationController.backgroundColor = [UIColor grayColor]; // iOS 8 style

I'm 90% sure this is actually a bug in Apple's implementation. The value I see in the backgroundColor after rotation property is correct, but the pixels drawn are not. I wonder if anybody else has experienced this issue and found work arounds. If there is a radar open I'll follow it, if not I'll submit one myself.

I'll add how I am presenting the popover. In both versions I use a barButtonItem as my anchor.

[self.menuPopoverController presentPopoverFromBarButtonItem:item permittedArrowDirections:UIPopoverArrowDirectionAny animated:animated];

Here it is using the new iOS8 UIPresentationPopoverController:

UIPopoverPresentationController *popover = self.popoverPresentationController;
popover.permittedArrowDirections = UIPopoverArrowDirectionAny;
popover.barButtonItem = item;
[viewController presentViewController:self animated:YES completion:nil];  // I'm presenting a view controller from within itself.
0

There are 0 answers