UIPopoverPresentationController / UIPopoverController loses backgroundColor when rotating the interface

I have a menu in iOS that I show in a popover. I can imagine popover in both iOS7 and iOs8 using the UIPopoverController and UIPopoverPresentation controllers respectively. I ran into a problem though, when the popover is visible and the device is spinning, the popover disappears for a second of a second during the animation, and then appears after the animation. The problem is that when a popover reappears, its background color is drawn as the default background color.

I set the color using the backgroundColor property.

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

I am 90% sure that this is actually a mistake in the implementation of Apple. The value that I see in the backgroundColor property after rotation is correct, but the pixels drawn are not. Interestingly, anyone else experienced this problem and found work around. If the radar is open, I will follow it; if not, I will send it myself.

I will add how I present a popover. In both versions, I use barButtonItem as my anchor.

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

It uses 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. 
+5
source share

Source: https://habr.com/ru/post/1206666/


All Articles