Jelajahi Sumber

综合 - 文档损坏打开崩溃修复

dinglingui 1 tahun lalu
induk
melakukan
6d3a3f5f33

+ 12 - 9
ComPDFKit_Tools/ComPDFKit_Tools/Viewer/PDFThumbnail/CPDFThumbnailViewController.m

@@ -128,21 +128,24 @@
     
     [self.collectionView reloadData];
 
-    NSIndexPath *indexPath = [NSIndexPath indexPathForItem:self.pdfView.currentPageIndex inSection:0];
-    [self.collectionView selectItemAtIndexPath:indexPath
-                                      animated:NO
-                                scrollPosition:UICollectionViewScrollPositionCenteredVertically];
+    if(self.pdfView.document) {
+        NSIndexPath *indexPath = [NSIndexPath indexPathForItem:self.pdfView.currentPageIndex inSection:0];
+        [self.collectionView selectItemAtIndexPath:indexPath
+                                          animated:NO
+                                    scrollPosition:UICollectionViewScrollPositionCenteredVertically];
+    }
 }
 
 
 - (void)viewDidAppear:(BOOL)animated {
     [super viewDidAppear:animated];
 
-    NSIndexPath *indexPath = [NSIndexPath indexPathForItem:self.pdfView.currentPageIndex inSection:0];
-    [self.collectionView scrollToItemAtIndexPath:indexPath
-                                atScrollPosition:UICollectionViewScrollPositionCenteredVertically
-                                        animated:NO];
-
+    if(self.pdfView.document) {
+        NSIndexPath *indexPath = [NSIndexPath indexPathForItem:self.pdfView.currentPageIndex inSection:0];
+        [self.collectionView scrollToItemAtIndexPath:indexPath
+                                    atScrollPosition:UICollectionViewScrollPositionCenteredVertically
+                                            animated:NO];
+    }
 }
 
 #pragma mark - Class method