2
votes

I am creating a OSX PDF viewer application. At the bottom there is a horizontal scroll bar so the user can easily scroll between pages. When scrolling there is a small preview window showing a preview of that page. This works fine under OSX 10.7 and 10.8 but in Mavericks 10.9 the "Automatically scale" option does seem to loose its effect. There is also a scrollbar (even if setting the scale to a value that does not require a scrollbar).

Any ideas on how to solve this?

OSX 10.7 and 10.8:

OSX 10.7 and 10.8

OSX Mavericks:

OSX Mavericks

Code for setting up the view:

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

The view structure from 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

I have also tested with setNeedsLayout:YES and setNeedsDisplay:YES on both _pdfView and self without any change.

Any suggestions?

3
Same problem. However, when I resize the window, it automatically scales.Colas

3 Answers

4
votes

Try this:

self.pdfView.autoScales = NO;
self.pdfView.document = _currentDocument
self.pdfView.autoScales = YES;

It worked for me, so hopefully for you.

0
votes

Seems to be a bug. Solved it by resizing the super view. Then it automatically resized.

//int widthModifierForMavericksWorkaround = 1;

-(void)refresh
{
    // Ugly workaround for Mavericks, resize view so it updates its scale

    CGSize size = self.frame.size;
    size.width += widthModifierForMavericksWorkaround;
    [self resizeSubviewsWithOldSize:size];

    widthModifierForMavericksWorkaround *= -1;
}
0
votes

Try to do so, after having loaded your pdf document:

[self.pdfView setDocument:pdfDoc];
[self.pdfView zoomIn:self];
[self.pdfView setAutoScales:YES];