Browse Source

菜单栏-前往-前往第几页,输入第1页,会直接跳转到第2页(已修复)

tangchao 1 year ago
parent
commit
c7c1062a73

BIN
PDF Office/PDF Office.xcodeproj/project.xcworkspace/xcuserdata/kdanmobile.xcuserdatad/UserInterfaceState.xcuserstate


+ 48 - 0
PDF Office/PDF Office.xcodeproj/xcuserdata/kdanmobile.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist

@@ -308,5 +308,53 @@
             landmarkType = "7">
          </BreakpointContent>
       </BreakpointProxy>
+      <BreakpointProxy
+         BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
+         <BreakpointContent
+            uuid = "F4D06208-ED91-41A3-AD94-A8FA46196147"
+            shouldBeEnabled = "No"
+            ignoreCount = "0"
+            continueAfterRunningActions = "No"
+            filePath = "PDF Office/Class/PDFTools/PageEdit/Controller/KMPDFEditViewController.swift"
+            startingColumnNumber = "9223372036854775807"
+            endingColumnNumber = "9223372036854775807"
+            startingLineNumber = "1568"
+            endingLineNumber = "1568"
+            landmarkName = "thumbnailView(thumbanView:itemForRepresentedObjectAt:)"
+            landmarkType = "7">
+            <Locations>
+               <Location
+                  uuid = "F4D06208-ED91-41A3-AD94-A8FA46196147 - a53cf8aecf657d12"
+                  shouldBeEnabled = "Yes"
+                  ignoreCount = "0"
+                  continueAfterRunningActions = "No"
+                  symbolName = "PDF_Office.KMPDFEditViewController.thumbnailView(thumbanView: PDF_Office.KMPDFThumbnailView, itemForRepresentedObjectAt: Foundation.IndexPath) -&gt; __C.NSCollectionViewItem"
+                  moduleName = "PDF Office"
+                  usesParentBreakpointCondition = "Yes"
+                  urlString = "file:///Users/kdanmobile/work/tangchao/git/PDFOffice/PDF%20Office/PDF%20Office/Class/PDFTools/PageEdit/Controller/KMPDFEditViewController.swift"
+                  startingColumnNumber = "9223372036854775807"
+                  endingColumnNumber = "9223372036854775807"
+                  startingLineNumber = "1570"
+                  endingLineNumber = "1570"
+                  offsetFromSymbolStart = "1566">
+               </Location>
+               <Location
+                  uuid = "F4D06208-ED91-41A3-AD94-A8FA46196147 - f52e7541503b354a"
+                  shouldBeEnabled = "Yes"
+                  ignoreCount = "0"
+                  continueAfterRunningActions = "No"
+                  symbolName = "closure #1 (Any...) -&gt; () in PDF_Office.KMPDFEditViewController.thumbnailView(thumbanView: PDF_Office.KMPDFThumbnailView, itemForRepresentedObjectAt: Foundation.IndexPath) -&gt; __C.NSCollectionViewItem"
+                  moduleName = "PDF Office"
+                  usesParentBreakpointCondition = "Yes"
+                  urlString = "file:///Users/kdanmobile/work/tangchao/git/PDFOffice/PDF%20Office/PDF%20Office/Class/PDFTools/PageEdit/Controller/KMPDFEditViewController.swift"
+                  startingColumnNumber = "9223372036854775807"
+                  endingColumnNumber = "9223372036854775807"
+                  startingLineNumber = "1570"
+                  endingLineNumber = "1570"
+                  offsetFromSymbolStart = "123">
+               </Location>
+            </Locations>
+         </BreakpointContent>
+      </BreakpointProxy>
    </Breakpoints>
 </Bucket>

+ 3 - 0
PDF Office/PDF Office/Class/PDFWindowController/Side/LeftSide/Thumbnail/KMPDFThumbnailView.swift

@@ -302,6 +302,9 @@ extension KMPDFThumbnailView: NSCollectionViewDelegate {
             if dragIndex < 0 || dragIndex > self.document.pageCount {
                 return false
             }
+            if (toIndex >= self.document.pageCount) {
+                return false
+            }
             
             if dragIndex == toIndex {
                 return false

+ 14 - 3
PDF Office/PDF Office/Class/PDFWindowController/ViewController/KMMainViewController+MenuAction.swift

@@ -538,12 +538,23 @@ extension KMMainViewController {
         for i in 0 ..< self.listView.document.pageCount {
             pages.append("\(i)")
         }
-        sheet.callback =  { stingValue in
-            self.listView.go(toPageIndex: Int(sheet.stringValue)!, animated: true)
+        sheet.callback =  { [weak self] stringValue in
+            if (stringValue == nil) {
+                return
+            }
+            guard let index = Int(stringValue!) else {
+                return
+            }
+            if (self?.listView == nil) {
+                return
+            }
+            if (index > 0 && index <= self!.listView.document.pageCount) {
+                self?.listView.go(toPageIndex: index-1, animated: true)
+            }
         }
         sheet.showWindow(nil)
         sheet.pageBox.addItems(withObjectValues: pages)
-        sheet.stringValue = "\(self.listView.currentPageIndex)"
+        sheet.stringValue = "\(self.listView.currentPageIndex+1)"
     }
 }
 

+ 11 - 0
PDF Office/PDF Office/Class/PDFWindowController/ViewController/SKTextFieldSheetController.m

@@ -38,10 +38,19 @@
 
 #import "SKTextFieldSheetController.h"
 
+static SKTextFieldSheetController *windowController = nil;
+
 @implementation SKTextFieldSheetController
 
+- (void)dealloc {
+    NSLog(@"%s", __func__);
+}
+
 
 - (void)windowDidLoad {
+    [super windowDidLoad];
+    
+    windowController = self;
     self.pageLabel.stringValue = NSLocalizedString(@"Page:", nil);
 }
 
@@ -57,12 +66,14 @@
     if(self.callback && sender == self.okButton) {
         self.callback(self.stringValue);
     }
+    
     if (@available(macOS 10.13, *)) {
         [NSApp endSheet:[self window] returnCode:[sender tag]];
     } else {
         [NSApp endSheet:[self window]];
     }
     [[self window] orderOut:self];
+    windowController = nil;
 }
 
 @end