Quellcode durchsuchen

Merge pull request #2009 from nextcloud/fix/varie

Fix/varie
Marino Faggiana vor 3 Jahren
Ursprung
Commit
eb4ee227af

+ 2 - 2
Nextcloud.xcodeproj/project.pbxproj

@@ -3006,7 +3006,7 @@
 				CLANG_WARN_UNREACHABLE_CODE = YES;
 				CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
 				COPY_PHASE_STRIP = NO;
-				CURRENT_PROJECT_VERSION = 10;
+				CURRENT_PROJECT_VERSION = 11;
 				DEVELOPMENT_TEAM = 6JLRKY9ZV7;
 				ENABLE_BITCODE = NO;
 				ENABLE_STRICT_OBJC_MSGSEND = YES;
@@ -3067,7 +3067,7 @@
 				CLANG_WARN_UNREACHABLE_CODE = YES;
 				CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
 				COPY_PHASE_STRIP = NO;
-				CURRENT_PROJECT_VERSION = 10;
+				CURRENT_PROJECT_VERSION = 11;
 				DEVELOPMENT_TEAM = 6JLRKY9ZV7;
 				ENABLE_BITCODE = NO;
 				ENABLE_STRICT_OBJC_MSGSEND = YES;

+ 0 - 2
iOSClient/Brand/iOSClient.plist

@@ -117,8 +117,6 @@
 		<string>UIInterfaceOrientationLandscapeRight</string>
 		<string>UIInterfaceOrientationPortraitUpsideDown</string>
 	</array>
-	<key>UISupportsDocumentBrowser</key>
-	<true/>
 	<key>UIViewControllerBasedStatusBarAppearance</key>
 	<true/>
 	<key>UTExportedTypeDeclarations</key>

+ 30 - 14
iOSClient/Viewer/NCViewerPDF/NCViewerPDF.swift

@@ -474,6 +474,8 @@ class NCViewerPDF: UIViewController, NCViewerPDFSearchDelegate {
 
     func searchPdfSelection(_ pdfSelection: PDFSelection) {
 
+        removeAllAnnotations()
+
         pdfSelection.pages.forEach { page in
             let highlight = PDFAnnotation(bounds: pdfSelection.bounds(for: page), forType: .highlight, withProperties: nil)
             highlight.endLineStyle = .square
@@ -490,20 +492,34 @@ class NCViewerPDF: UIViewController, NCViewerPDFSearchDelegate {
 
         guard let pdf = pdfView.document else { return }
 
-         if let pageNr = Int(label) {
-             if pageNr > 0 && pageNr <= pdf.pageCount {
-                 if let page = pdf.page(at: pageNr - 1) {
-                     self.pdfView.go(to: page)
-                 }
-             } else {
-                 let alertController = UIAlertController(title: NSLocalizedString("_invalid_page_", comment: ""),
-                                                         message: NSLocalizedString("_the_entered_page_number_doesn't_exist_", comment: ""),
-                                                         preferredStyle: .alert)
-                 alertController.addAction(UIAlertAction(title: NSLocalizedString("_ok_", comment: ""), style: .default, handler: nil))
-                 self.present(alertController, animated: true, completion: nil)
-             }
-         }
-     }
+        if let pageNr = Int(label) {
+            if pageNr > 0 && pageNr <= pdf.pageCount {
+                if let page = pdf.page(at: pageNr - 1) {
+                    self.pdfView.go(to: page)
+                }
+            } else {
+                let alertController = UIAlertController(title: NSLocalizedString("_invalid_page_", comment: ""),
+                                                        message: NSLocalizedString("_the_entered_page_number_doesn't_exist_", comment: ""),
+                                                        preferredStyle: .alert)
+                alertController.addAction(UIAlertAction(title: NSLocalizedString("_ok_", comment: ""), style: .default, handler: nil))
+                self.present(alertController, animated: true, completion: nil)
+            }
+        }
+    }
+
+    func removeAllAnnotations() {
+
+        guard let document = pdfDocument else { return }
+
+        for i in 0..<document.pageCount {
+            if let page = document.page(at: i) {
+                let annotations = page.annotations
+                for annotation in annotations {
+                    page.removeAnnotation(annotation)
+                }
+            }
+        }
+    }
 }
 
 extension NCViewerPDF: UIGestureRecognizerDelegate {