Skip to content

Commit

Permalink
Merge pull request #31 from p-x9/feature/fix-unbalanced-calls-transit…
Browse files Browse the repository at this point in the history
…ions

fix `Unbalanced calls to begin/end appearance transitions`
  • Loading branch information
p-x9 authored Sep 5, 2023
2 parents bafb63b + 67be11f commit 1ca480c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
13 changes: 10 additions & 3 deletions Sources/TouchTracker/Cocoa/TouchTrackingUIView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,9 @@ public class TouchTrackingUIView: UIView {
var touches: Set<UITouch> = []
var locations: [CGPoint] = [] {
didSet {
updatePoints()
DispatchQueue.main.async {
self.updatePoints()
}
}
}

Expand Down Expand Up @@ -164,7 +166,9 @@ public class TouchTrackingUIView: UIView {
pointWindows[touches.count..<pointWindows.count].forEach {
$0.isHidden = true
$0.windowScene = nil
$0.uiviewRemoveFormSuperView()
if $0.superview != nil {
$0.uiviewRemoveFromSuperView()
}
}
pointWindows = Array(pointWindows[0..<touches.count])
}
Expand Down Expand Up @@ -201,10 +205,13 @@ public class TouchTrackingUIView: UIView {
let screen = self.window?.screen,
let keyboardScene = UIWindowScene.keyboardScene(for: screen),
let keyboardRemoteWindow = keyboardScene.allWindows.first {
window.rootViewController = nil
keyboardRemoteWindow.addSubview(window)
} else {
// WORKAROUND: Apply changes of orientation
window.rootViewController = .init()
if window.rootViewController == nil {
window.rootViewController = .init()
}
window.windowScene = self.window?.windowScene
}

Expand Down
2 changes: 1 addition & 1 deletion Sources/TouchTracker/Extension/UIWindow+.swift
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ extension UIWindow {
}

extension UIWindow {
func uiviewRemoveFormSuperView() {
func uiviewRemoveFromSuperView() {
super.removeFromSuperview()
}
}
Expand Down

0 comments on commit 1ca480c

Please sign in to comment.