I try to display an FPPopover and for this I need a parentView. Everything is fine on first attempt. But after displaying a PDF in QuicklLookViewController, the number of subviews in windows is 0, so I cannot grasp the last element to use it as parentView... With a NSLog I can see that the last object of my view hierarchy is hidden, explaining probably why the count is 0. The lastObject seems to be this new kind of UITextEffectsWindow...
FPPopoverController.m
Init method
NSArray *windows = [UIApplication sharedApplication].windows;
if(windows.count > 0)
{
_parentView=nil;
_window = [windows lastObject];
NSLog(@"Window.subviews count: %d", _window.subviews.count); // --> return 1 if no PDF was previously seen with QuickLook --> So popover is displayed the first time.
//keep the first subview
if(_window.subviews.count > 0) // ---> subviews.count is 0 after displaying a PDF with QuickLook --> method not called the second time and popover is not displayed
{
_parentView = [_window.subviews lastObject];
[_parentView addSubview:self.view];
[_viewController viewDidAppear:YES];
NSLog(@"windows: %@" "window: %@", _windows, _window); // --> I can see that the last element is hidden after displaying the PDF (something not present before I display PDF with QuickLook...)
NSLog(@"Parentview: %@", _parentView);
}
Any ideas why this is happening? I cannot figure out why QuickLook returns no subviews or hides them... Any way to circumvent this issue?
UITextEffectsWindow seems to be the window hosting the keyboard. Anyway, you should refactor
FPPopover
(which is not maintained anymore) to be able to specify the parent view (and pass your view controller's view, or whatever is appropriate) instead of trying to find out a suitable one in the init method .This kind of view hierarchy exploration is highly discouraged as remote view controllers and keyboards sometimes manipulate the window list. If you really want to discover a view to add yourself to manually, it's better to start with the root view controller's view.