|
@@ -47,6 +47,16 @@ class KMThumbnailViewController: NSViewController {
|
|
|
NotificationCenter.default.removeObserver(self)
|
|
|
print("KMThumbnailViewController 释放")
|
|
|
}
|
|
|
+
|
|
|
+ override func viewWillAppear() {
|
|
|
+ super.viewWillAppear()
|
|
|
+ self.thumbnailView.reloadData()
|
|
|
+ }
|
|
|
+
|
|
|
+ override func centerSelectionInVisibleArea(_ sender: Any?) {
|
|
|
+ super.centerSelectionInVisibleArea(sender)
|
|
|
+ }
|
|
|
+
|
|
|
override func viewDidLoad() {
|
|
|
super.viewDidLoad()
|
|
|
self.view.wantsLayer = true
|
|
@@ -88,7 +98,6 @@ class KMThumbnailViewController: NSViewController {
|
|
|
|
|
|
NotificationCenter.default.addObserver(self, selector: #selector(AnnotationDidChangeNoti), name: NSNotification.Name.init(rawValue: "CPDFPageDidAddAnnotationNotification"), object: nil)
|
|
|
NotificationCenter.default.addObserver(self, selector: #selector(AnnotationDidChangeNoti), name: NSNotification.Name.init(rawValue: "CPDFPageDidRemoveAnnotationNotification"), object: nil)
|
|
|
-
|
|
|
}
|
|
|
|
|
|
func removeNotification() {
|
|
@@ -184,37 +193,43 @@ class KMThumbnailViewController: NSViewController {
|
|
|
|
|
|
//MARK: Noti
|
|
|
@objc func KMPDFViewCurrentPageDidChangedNotification(notification: NSNotification) {
|
|
|
- let pdfdocument : CPDFDocument = notification.object as! CPDFDocument
|
|
|
- if pdfdocument.isEqual(self.listView.document) {
|
|
|
- if !isLocalEvent {
|
|
|
-// DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + 0.3) { [unowned self] in
|
|
|
- self.pdfCurrentPageChange()
|
|
|
- self.delegate?.pageDidSelect?(controller: self, pages: [self.listView.currentPageIndex])
|
|
|
-// }
|
|
|
+ if notification.object is CPDFDocument {
|
|
|
+ let pdfdocument : CPDFDocument = notification.object as! CPDFDocument
|
|
|
+ if pdfdocument.isEqual(self.listView.document) {
|
|
|
+ if !isLocalEvent {
|
|
|
+ // DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + 0.3) { [unowned self] in
|
|
|
+ self.pdfCurrentPageChange()
|
|
|
+ self.delegate?.pageDidSelect?(controller: self, pages: [self.listView.currentPageIndex])
|
|
|
+ // }
|
|
|
+ }
|
|
|
+ isLocalEvent = false
|
|
|
}
|
|
|
- isLocalEvent = false
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@objc func KMPDFViewPageCountChangedNotification(notification: NSNotification) {
|
|
|
- let pdfdocument : CPDFDocument = notification.object as! CPDFDocument
|
|
|
- if pdfdocument.isEqual(self.listView.document) {
|
|
|
- if !isLocalEvent {
|
|
|
-// DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + 0.3) { [unowned self] in
|
|
|
- self.reloadData()
|
|
|
-// }
|
|
|
+ if notification.object is CPDFDocument {
|
|
|
+ let pdfdocument : CPDFDocument = notification.object as! CPDFDocument
|
|
|
+ if pdfdocument.isEqual(self.listView.document) {
|
|
|
+ if !isLocalEvent {
|
|
|
+ // DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + 0.3) { [unowned self] in
|
|
|
+ self.reloadData()
|
|
|
+ // }
|
|
|
+ }
|
|
|
+ isLocalEvent = false
|
|
|
}
|
|
|
- isLocalEvent = false
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@objc func AnnotationDidChangeNoti(notification: NSNotification) {
|
|
|
- let pdfAnnotation : CPDFAnnotation = notification.object as! CPDFAnnotation
|
|
|
-
|
|
|
- if (pdfAnnotation.page != nil) {
|
|
|
- var indexs: IndexSet = IndexSet()
|
|
|
- indexs.insert(IndexSet.Element(pdfAnnotation.page.pageIndex()))
|
|
|
- self.reloadDataAtIndexs(indexs: indexs)
|
|
|
+ if notification.object is CPDFAnnotation {
|
|
|
+ let pdfAnnotation : CPDFAnnotation = notification.object as! CPDFAnnotation
|
|
|
+
|
|
|
+ if (pdfAnnotation.page != nil) {
|
|
|
+ var indexs: IndexSet = IndexSet()
|
|
|
+ indexs.insert(IndexSet.Element(pdfAnnotation.page.pageIndex()))
|
|
|
+ self.reloadDataAtIndexs(indexs: indexs)
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|