【问题标题】:iOS - QuickLook returning no window subviewiOS - QuickLook 不返回窗口子视图
【发布时间】:2014-12-02 10:16:18
【问题描述】:

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

FPPopoverController.m

初始化方法

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 不返回子视图或隐藏它们......有什么办法可以规避这个问题?

【问题讨论】:

    标签: ios hidden subview uipopover quicklook


    【解决方案1】:

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

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-10-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-09-03
      相关资源
      最近更新 更多