iOS - QuickLook不返回窗口子视图

时间:2014-12-02 10:16:19

标签: ios hidden subview uipopover quicklook

我尝试显示FPPopover,为此我需要一个parentView。第一次尝试时一切都很好。但是在QuicklLookViewController中显示PDF后,windows中的子视图数量为0,所以我无法掌握最后一个元素将其用作parentView ...使用NSLog我可以看到我的视图层次结构的最后一个对象被隐藏,解释可能为什么计数为0. lastObject似乎是这种新的UITextEffectsWindow ......

FPPopoverController.m

Init方法

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

为什么会发生这种情况?我无法弄清楚为什么QuickLook不返回任何子视图或隐藏它们......有什么方法可以绕过这个问题吗?

1 个答案:

答案 0 :(得分:0)

UITextEffectsWindow似乎是托管键盘的窗口。无论如何,您应该重构FPPopover(不再维护)以便能够指定父视图(并传递视图控制器的视图,或任何适当的视图),而不是尝试在init中找到合适的视图方法。

由于远程视图控制器和键盘有时会操纵窗口列表,因此非常不鼓励这种视图层次结构探索。如果你真的想要发现一个手动添加自己的视图,最好从根视图控制器的视图开始。