我正在創建一個OSX PDF查看器應用程序。底部有一個水平滾動條,用戶可以在頁面之間輕鬆滾動。當滾動時,有一個小預覽窗口顯示該頁面的預覽。這在OSX 10.7和10.8下工作正常,但在Mavericks 10.9中,「自動縮放」選項似乎沒有效果。還有一個滾動條(即使將比例設置爲不需要滾動條的值)。PDFView在小牛不會「自動縮放」並始終顯示滾動條
關於如何解決這個問題的任何想法?
OSX 10.7和10.8:
OSX小牛:
代碼建立視圖:
- (void)awakeFromNib
{
[super awakeFromNib];
[_pdfView setAutoScales:YES];
[_pdfView setDisplayMode:kPDFDisplayTwoUp];
[_pdfView setDisplaysPageBreaks:NO];
[self setWantsLayer:YES];
}
- (void)drawRect:(NSRect)dirtyRect
{
[super drawRect:dirtyRect];
CGContextRef context = (CGContextRef) [[NSGraphicsContext currentContext] graphicsPort];
CGContextSetRGBFillColor(context, 0.227,0.251,0.337,0.8);
CGContextFillRect(context, NSRectToCGRect(dirtyRect));
}
從po [self.previewView _subtreeDescription]
的視圖結構:
$0 = 0x0000000113dcd280 [ A WLU#] h=&-& v=--& IBPreviewView 0x119554760 f=(730.097,47,300,200) b=(-) => <_NSViewBackingLayer: 0x110a5b800> TIME drawRect: min/mean/max 0.00/0.00/0.00 ms
[ O WlU ] h=-&- v=-&- PDFView 0x104cb9c20 f=(10,60,280,130) b=(-) => <_NSViewBackingLayer: 0x114e311a0> TIME drawRect: min/mean/max 0.00/0.00/0.00 ms
[ AF O wlU ] h=--- v=--- PDFViewScrollView 0x110a36c60 f=(0,0,280,130) b=(-) => <_NSViewBackingLayer: 0x110a374a0> TIME drawRect: min/mean/max 0.00/0.00/0.00 ms
[ AF O wlU ] h=--- v=--- PDFCenteringClipView 0x110a2ba30 f=(0,0,265,130) b=(0.5,0,-,-) => <_NSClipViewBackingLayer: 0x110a42b70> TIME drawRect: min/mean/max 0.00/0.00/0.00 ms
[ AF O WLU ] h=--- v=--- PDFMatteView 0x110a28730 f=(0,0,980,683) b=(-) => <_NSViewBackingLayer: 0x110a3b600> TIME drawRect: min/mean/max 0.00/0.00/0.00 ms
[ A LU ] h=--- v=--- PDFDisplayView 0x114e309b0 f=(0,0,980,683) b=(-) TIME drawRect: min/mean/max 0.00/0.00/0.00 ms
[ AF wlU ] h=--- v=--- NSScroller 0x100766e50 f=(265,0,15,130) b=(-) => <_NSViewBackingLayer: 0x100766e20> TIME drawRect: min/mean/max 0.00/0.00/0.00 ms
[ AF wlU ] h=-&- v=-&- NSTextField 0x104c87110 f=(7,27,286,25) b=(-) => <_NSViewBackingLayer: 0x110a5b910> TIME drawRect: min/mean/max 0.00/0.00/0.00 ms
[ AF wlU ] h=-&- v=-&- NSTextField 0x110a2ef60 "76 av 152" f=(89,0,115,25) b=(-) => <_NSViewBackingLayer: 0x110a5b970> TIME drawRect: min/mean/max 0.00/0.00/0.00 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
我也有兩個_pdfView setNeedsLayout:YES
和setNeedsDisplay:YES
和自我測試,沒有任何變化。
有什麼建議嗎?
同樣的問題。但是,當我調整窗口大小時,它會自動縮放。 – Colas