6 Replies
      Latest reply on Jan 28, 2017 7:53 AM by mixage
      diederik Level 1 Level 1 (0 points)

        Hi,

         

        Does anybody know a workaround for the bug that PDFThumbnailView is no longer working (thumbnails cannot be selected anymore) on macOS Sierra?

         

        rdar://28754282

        • Re: PDFThumbnailView broken on macOS 10.12
          danielv Level 1 Level 1 (0 points)

          Same here. Couldn't find any way to make it respond to selecting and dragging again. Will probably just ditch it altogether and roll out my own based on a collection view.

            • Re: PDFThumbnailView broken on macOS 10.12
              HOsy Level 1 Level 1 (0 points)

              Did you find a solution for the selection problem or can you share your collection view? Thank you!

                • Re: PDFThumbnailView broken on macOS 10.12
                  danielv Level 1 Level 1 (0 points)

                  I didn't get around to writing my own PDFThumbnailView replacement yet. I want to check wheter 10.12.2 update solves any of the PDFKit problems before I decide how to approach this and the many other PDFKit issues.

                    • Re: PDFThumbnailView broken on macOS 10.12
                      vfr Level 1 Level 1 (0 points)

                      PDFThumbnailView continues to be broken in macOS 10.12.3 beta 1.

                       

                      Also filed a bug report: #29739427.

                       

                       

                        • Re: PDFThumbnailView broken on macOS 10.12
                          HOsy Level 1 Level 1 (0 points)

                          I cannot wait for a fix in 10.3. I need also a fallback for 10.12.1 an 10.12.2. I wrote my own PDFThumbnailView implementation which should work as expected.

                          Search on Github for HSPDFThumbnailView.

                           

                          I hope it will also work for your projects.

                            • Re: PDFThumbnailView broken on macOS 10.12
                              mixage Level 1 Level 1 (0 points)

                              Thanks for your code :-) I've just added a check on selectionIndex to prevent a potential crash

                               

                              - (void)observeValueForKeyPath:(NSString *)keyPath

                                                    ofObject:(id)object

                                                      change:(NSDictionary *)change

                                                     context:(void *)context

                              {

                                  if ([keyPath isEqualToString:@"selectedObjects"])

                                  {

                                if ( self.arrayController.selectionIndex != NSNotFound )

                                [self.PDFView goToPage:[self.PDFView.document pageAtIndex:self.arrayController.selectionIndex]];

                                  }

                                  else if ([keyPath isEqualToString:@"document"])

                                  {

                                      [self willChangeValueForKey:@"items"];

                                    

                                      [self.items removeAllObjects];

                                    

                                      for (int i=0; i < self.PDFView.document.pageCount; i++)

                                      {

                                          NSMutableDictionary *newDict = [NSMutableDictionary new];

                                          [newDict setObject:[NSString stringWithFormat:@"%d", (i + 1)] forKey:@"label"];

                                          [newDict setObject:[self.PDFView.document pageAtIndex:i] forKey:@"page"];

                                        

                                          [self.items addObject:newDict];

                                      }

                                      [self didChangeValueForKey:@"items"];

                                  }

                              }