Forráskód Böngészése

【阅读页】缩放按钮、上一页/下一页 按钮,若是功能不支持置灰

liaoxiaoyue 1 éve
szülő
commit
cceb020d80

+ 17 - 0
PDF Office/PDF Office/Class/PDFWindowController/ViewController/KMMainViewController+Action.swift

@@ -1258,6 +1258,21 @@ extension KMMainViewController {
             return false
         }
     }
+    
+    func updateNextAndPreViousButtonState() {
+        let item : KMToolBoxItem = (self.toolbarController.mainToolBarView?.toolbarItemFindItemIdentifiers(value: KMDocumentNextPageToolbarItemIdentifier))!
+        let toItem : KMToolBoxItem = (self.toolbarController.mainToolBarView?.toolbarItemFindItemIdentifiers(value: KMDocumentPreviousPageToolbarItemIdentifier))!
+        if self.listView.canGoToNextPage() {
+            item.unEnabled = false
+        } else {
+            item.unEnabled = true
+        }
+        if self.listView.canGoToPreviousPage() {
+            toItem.unEnabled = false
+        } else {
+            toItem.unEnabled = true
+        }
+    }
 }
 
 extension KMMainViewController: KMSecondaryViewControllerDelegate {
@@ -1342,10 +1357,12 @@ extension KMMainViewController : KMMainToolbarControllerDelegate {
     
     func changePDFViewGotoNextPageAction() {
         self.listView.goToNextPage(nil)
+        self.updateNextAndPreViousButtonState()
     }
     
     func changePDFViewGoToPreviousPageAction() {
         self.listView.goToPreviousPage(nil)
+        self.updateNextAndPreViousButtonState()
     }
     
     func showPDFViewPrintViewController() {