macos - OSX Mavericks 中的 PDFKit (10.9)

标签 macos pdf osx-mavericks

我正在为 OSX 创建 PDF 应用程序。我正在使用 Apple 的 PDFKit 框架来执行此操作。

但是,在 Mavericks (OSX 10.9) 上运行应用程序时,PDF View 始终绘制在前面!这意味着在 10.8 上显示在 pdf View 前面的 View 现在绘制在它的后面! OSX 10.8 或更低版本的情况并非如此。

我尝试在 XCode 5 中使用 10.9 sdk 构建 10.9,但没有成功。应用程序最好支持 10.7,我之前在 XCode 4 中使用过 10.8 sdk。

这就是我的观点:

- PDF View
  - View 1
- View 2

首先渲染第一个 View (在其他 View 下方)。

它们在 OSX 10.8 及更低版本中以这种方式绘制:

  1. 查看 2
  2. 查看 1
  3. PDF 查看

但是在 OSX 10.9 中绘制的是:

  1. 查看 1
  2. PDF 查看
  3. 查看 2

有什么想法吗?

这是 10.8 上的 View 结构,来自 [parentView _subtreeDescription]:

$0 = 0x000000010e918740 [   A      LU ] h=--- v=--- NSView 0x1025de1e0 f=(0,1,809,755) b=(-) TIME drawRect: min/mean/max 0.00/0.00/0.00 ms
  [   AF     LU ] h=-&- v=&-- PSMTabBarControl 0x11963b330 f=(0,733,809,22) b=(-) TIME drawRect: min/mean/max 0.41/0.54/0.71 ms
    [  HAF     LU ] h=&-- v=--- PSMOverflowPopUpButton 0x119427640 f=(781,0,14,22) b=(-) TIME drawRect: min/mean/max 0.00/0.00/0.00 ms
    [  HAF     LU ] h=--- v=--- PSMRolloverButton 0x11943db20 f=(0,0,0,0) b=(-) TIME drawRect: min/mean/max 0.00/0.00/0.00 ms
  [    F O   LU ] h=-&- v=-&- NSTabView 0x1025ec850 f=(0,0,809,718) b=(-) TIME drawRect: min/mean/max 0.00/0.00/0.00 ms
    [      O   LU ] h=-&- v=-&- IBEditPDFView 0x1051233f0 f=(0,0,809,718) b=(-) TIME drawRect: min/mean/max 0.00/0.00/0.00 ms
      [   AF O   LU ] h=--- v=--- PDFViewScrollView 0x105124230 f=(0,0,809,718) b=(-) TIME drawRect: min/mean/max 0.00/0.00/0.00 ms
        [   AF OGP LU ] h=--- v=--- NSClipView 0x105124530 f=(0,0,809,718) b=(-) TIME drawRect: min/mean/max 0.00/0.00/0.00 ms
          [   AF O   LU ] h=--- v=--- PDFMatteView 0x105123670 f=(0,0,809,718) b=(-) TIME drawRect: min/mean/max 0.23/0.28/0.39 ms
            [   A      LU ] h=--- v=--- PDFDisplayView 0x105103c50 f=(148,0,513,718) b=(-) TIME drawRect: min/mean/max 0.27/1.98/9.80 ms
            //...
        [  HAF     LU ] h=--- v=--- NSScroller 0x1004a09f0 f=(-100,-100,15,755) b=(-) TIME drawRect: min/mean/max 0.00/0.00/0.00 ms
  [   AF     LU ] h=--& v=&-& NSButton 0x10258dc70 f=(20,328,40,60) b=(-) TIME drawRect: min/mean/max 0.15/0.71/2.33 ms
  [   AF     LU ] h=&-- v=&-& NSButton 0x11945ab10 f=(749,328,40,60) b=(-) TIME drawRect: min/mean/max 0.10/9.84/56.55 ms

A=autoresizesSubviews, C=canDrawConcurrently, D=needsDisplay, F=flipped, G=gstate, H=hidden (h=by ancestor), L=needsLayout (l=child needsLayout), U=needsUpdateConstraints (u=child needsUpdateConstraints), O=opaque, P=preservesContentDuringLiveResize, S=scaled/rotated, W=wantsLayer (w=ancestor wantsLayer), #=has surface

这是(错误的)Mavericks View 结构:

$0 = 0x000000010044c7d0 [   A      LU ] h=--- v=--- NSView 0x114d37760 f=(0,1,2119,1172) b=(-) TIME drawRect: min/mean/max 0.00/0.00/0.00 ms
  [   AF     LU ] h=-&- v=&-- PSMTabBarControl 0x114d2d8a0 f=(0,1150,2119,22) b=(-) TIME drawRect: min/mean/max 0.44/0.70/1.11 ms
    [  HAF     LU ] h=&-- v=--- PSMOverflowPopUpButton 0x114d187c0 f=(2091,0,14,22) b=(-) TIME drawRect: min/mean/max 0.00/0.00/0.00 ms
    [  HAF     LU ] h=--- v=--- PSMRolloverButton 0x114d15770 f=(0,0,0,0) b=(-) TIME drawRect: min/mean/max 0.00/0.00/0.00 ms
  [    F O   LU ] h=-&- v=-&- NSTabView 0x105224c10 f=(0,0,2119,1135) b=(-) TIME drawRect: min/mean/max 0.02/1.00/14.27 ms
    [      O  WlU#] h=-&- v=-&- IBEditPDFView 0x1051226e0 f=(0,0,2119,1135) b=(-) => <_NSViewBackingLayer: 0x10513d330> TIME drawRect: min/mean/max 0.00/0.00/0.00 ms
      [   AF O  wlU ] h=--- v=--- PDFViewScrollView 0x10511ba90 f=(0,0,2119,1135) b=(-) => <_NSViewBackingLayer: 0x1051471d0> TIME drawRect: min/mean/max 0.00/0.00/0.00 ms
        [   AFSO  wlU ] h=--- v=--- PDFCenteringClipView 0x105126540 f=(0,0,2119,1135) b=(-388.943,1.35222e-13,1260.2,675) => <_NSClipViewBackingLayer: 0x1051478f0> TIME drawRect: min/mean/max 0.00/0.00/0.00 ms
          [   AFSO  WLU ] h=--- v=--- PDFMatteView 0x10511a910 f=(0,0,482,675) b=(-) => <_NSViewBackingLayer: 0x10512a970> TIME drawRect: min/mean/max 0.00/0.00/0.00 ms
            [   A S    LU ] h=--- v=--- PDFDisplayView 0x1051240c0 f=(0,0,482,675) b=(-) TIME drawRect: min/mean/max 0.00/0.00/0.00 ms
              //...
        [  HAF    wlU ] h=--- v=--- NSScroller 0x1051f8d00 f=(-100,-100,15,755) b=(-) => <_NSViewBackingLayer: 0x1051f8cd0> TIME drawRect: min/mean/max 0.00/0.00/0.00 ms
  [   AF     LU ] h=--& v=&-& NSButton 0x105224840 f=(20,524,40,60) b=(-) TIME drawRect: min/mean/max 0.12/0.34/11.62 ms
  [   AF     LU ] h=&-- v=&-& NSButton 0x105224470 f=(2059,524,40,60) b=(-) TIME drawRect: min/mean/max 0.09/0.11/0.41 ms

A=autoresizesSubviews, C=canDrawConcurrently, D=needsDisplay, F=flipped, G=gstate, H=hidden (h=by ancestor), L=needsLayout (l=child needsLayout), U=needsUpdateConstraints (u=child needsUpdateConstraints), O=opaque, P=preservesContentDuringLiveResize, S=scaled/rotated, W=wantsLayer (w=ancestor wantsLayer), #=has surface

这似乎不是订单的任何重新定位,但 Mavericks 为其某些 PDFKit View 设置了新标志,这可能会导致问题。

W、w、l 和 # 是新的。即“wantsLayer”、“祖先wantsLayer”、“子needsLayout”和“has surface”。

知道如何修改这些或有关如何解决此问题的任何线索吗?

最佳答案

Mavericks 中的 PDFKit View 似乎正在使用 Layer-backed。将我的重叠 View 设置为相同解决了问题。

[self.nextButton setWantsLayer:YES];
[self.prevButton setWantsLayer:YES];
[self.overlayViewController.view setWantsLayer:YES];

关于macos - OSX Mavericks 中的 PDFKit (10.9),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19640669/

相关文章:

macos - 如何将环境变量传递给由 Intellij IDEA 管理的 gradle 构建文件

python - 安装 X 协议(protocol)以使用 mysql shell - Mac

c++ - 在 Linux 中链接时发生库冲突,但在 OSX 中则不会

java - 生成并使用 PDF 底部的条形码

ruby - mac os x 10.9-brew 服务器需要 sinatra 错误

gcc - Cuda Clang 和 OS X Mavericks

php - 在 mountain lion 上安装 php intl 扩展

pdf - 将 Three.js 转换为 Adob​​e 3D-pdf?

ios 从 DocumentsDirectory 打开 ibooks 中的 pdf

objective-c - 在 OSX 中为给定进程禁用定时器合并