Skip to content

Commit f6329c7

Browse files
committed
fix(ios): annotations may persist on recycled views
1 parent 8b3ab9c commit f6329c7

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

ios/PdfView.swift

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44

55
@objc(PdfViewImpl)
66
public class PdfView: UIView {
7-
private var annotation = "" { didSet { loadAnnotation(file: true) } }
8-
private var annotationStr = "" { didSet { loadAnnotation(file: false) } }
7+
private var annotation = ""
8+
private var annotationStr = ""
99
private var page = 0
1010
private var resizeMode = ResizeMode.CONTAIN
1111
private var source = ""
@@ -60,24 +60,29 @@ public class PdfView: UIView {
6060
@objc public func updateProps(annotStr: String) {
6161
if annotationStr != annotStr {
6262
annotationStr = annotStr
63-
renderPdf()
63+
loadAnnotation(file: false)
6464
}
6565
}
6666

6767
@objc public func prepareForRecycle() {
6868
source = ""
6969
resizeMode = ResizeMode.CONTAIN
7070
previousSize = .zero
71+
annotation = ""
72+
annotationStr = ""
73+
annotLayer.setAnnotationData([])
7174
}
7275

7376
@objc public func updateProps(annot: String, annotStr: String, pg: Int, rsMd: ResizeMode, src: String) {
7477
var isDirty = false
7578
var needsMeasure = false
7679
if annotation != annot {
7780
annotation = annot
81+
loadAnnotation(file: true)
7882
}
7983
if annotationStr != annotStr {
8084
annotationStr = annotStr
85+
loadAnnotation(file: false)
8186
}
8287
if page != pg {
8388
page = pg

0 commit comments

Comments
 (0)