Browse Source

【2025】【BOTA 】缩略图列表 - 切换选中不同的缩略图时,缩略图列表会跳来跳去 - 修复

lizhe 3 weeks ago
parent
commit
3f46d618a6

+ 8 - 0
PDF Office/PDF Master/KMClass/KMNPDFPageEdit/KMNThumbnailView/KMNThumbnailBaseViewController.swift

@@ -54,6 +54,7 @@ class KMNThumbnailBaseViewController: KMNBaseViewController,NSCollectionViewDele
 
     private var currentDocument:CPDFDocument?
     private var isChangeIndexPaths = false
+    private var selectCount = 0 //防止点击缩图后 listview回调
     
     var lockedFiles: [URL] = []
     var filePromiseQueue: OperationQueue = {
@@ -152,6 +153,11 @@ class KMNThumbnailBaseViewController: KMNBaseViewController,NSCollectionViewDele
     
     var selectionIndexPaths: Set<IndexPath> = [] {
         didSet {
+            if selectCount != 0 {
+                selectCount -= 1
+                return
+            }
+            
             pdfviewSelectionIndexPaths = selectionIndexPaths
             var indexpaths: Set<IndexPath> = []
             for indexpath in selectionIndexPaths {
@@ -413,6 +419,8 @@ class KMNThumbnailBaseViewController: KMNBaseViewController,NSCollectionViewDele
     
     func collectionView(_ collectionView: NSCollectionView, didSelectItemsAt indexPaths: Set<IndexPath>) {
         if isChangeIndexPaths == false {
+            selectCount += 1
+            
             let indexpathsz = collectionView.selectionIndexPaths
             let dex:IndexSet = KMNTools.indexpathsToIndexs(indexpaths: indexpathsz)
             let selectedIndexPathsString = KMNTools.parseIndexSet(indexSet: dex)