Skip to content

Commit 1ca480c

Browse files
authored
Merge pull request #31 from p-x9/feature/fix-unbalanced-calls-transitions
fix `Unbalanced calls to begin/end appearance transitions`
2 parents bafb63b + 67be11f commit 1ca480c

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

Sources/TouchTracker/Cocoa/TouchTrackingUIView.swift

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,9 @@ public class TouchTrackingUIView: UIView {
5151
var touches: Set<UITouch> = []
5252
var locations: [CGPoint] = [] {
5353
didSet {
54-
updatePoints()
54+
DispatchQueue.main.async {
55+
self.updatePoints()
56+
}
5557
}
5658
}
5759

@@ -164,7 +166,9 @@ public class TouchTrackingUIView: UIView {
164166
pointWindows[touches.count..<pointWindows.count].forEach {
165167
$0.isHidden = true
166168
$0.windowScene = nil
167-
$0.uiviewRemoveFormSuperView()
169+
if $0.superview != nil {
170+
$0.uiviewRemoveFromSuperView()
171+
}
168172
}
169173
pointWindows = Array(pointWindows[0..<touches.count])
170174
}
@@ -201,10 +205,13 @@ public class TouchTrackingUIView: UIView {
201205
let screen = self.window?.screen,
202206
let keyboardScene = UIWindowScene.keyboardScene(for: screen),
203207
let keyboardRemoteWindow = keyboardScene.allWindows.first {
208+
window.rootViewController = nil
204209
keyboardRemoteWindow.addSubview(window)
205210
} else {
206211
// WORKAROUND: Apply changes of orientation
207-
window.rootViewController = .init()
212+
if window.rootViewController == nil {
213+
window.rootViewController = .init()
214+
}
208215
window.windowScene = self.window?.windowScene
209216
}
210217

Sources/TouchTracker/Extension/UIWindow+.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ extension UIWindow {
7777
}
7878

7979
extension UIWindow {
80-
func uiviewRemoveFormSuperView() {
80+
func uiviewRemoveFromSuperView() {
8181
super.removeFromSuperview()
8282
}
8383
}

0 commit comments

Comments
 (0)