From 850d58b976ff4f87deaebeac344d207f83f1d335 Mon Sep 17 00:00:00 2001 From: LeonX Date: Sun, 4 Jan 2026 10:26:01 +0800 Subject: [PATCH] fix/viewmodel-touch-events --- Example-iOS/Source/Examples/ViewModel/RiveButton.swift | 6 +++--- Example-iOS/Source/Examples/ViewModel/RiveSlider.swift | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Example-iOS/Source/Examples/ViewModel/RiveButton.swift b/Example-iOS/Source/Examples/ViewModel/RiveButton.swift index cee15e68..7765ebd6 100644 --- a/Example-iOS/Source/Examples/ViewModel/RiveButton.swift +++ b/Example-iOS/Source/Examples/ViewModel/RiveButton.swift @@ -23,18 +23,18 @@ class RiveButton: RiveViewModel { .frame(width: 100, height: 30) } - func touchBegan(onArtboard artboard: RiveArtboard?, atLocation location: CGPoint) { + @objc func touchBegan(onArtboard artboard: RiveArtboard?, atLocation location: CGPoint) { stop() setInput(input, value: true) } - func touchEnded(onArtboard artboard: RiveArtboard?, atLocation location: CGPoint) { + @objc func touchEnded(onArtboard artboard: RiveArtboard?, atLocation location: CGPoint) { stop() action?() touchCancelled(onArtboard: artboard, atLocation: location) } - func touchCancelled(onArtboard artboard: RiveArtboard?, atLocation location: CGPoint) { + @objc func touchCancelled(onArtboard artboard: RiveArtboard?, atLocation location: CGPoint) { setInput(input, value: false) } } diff --git a/Example-iOS/Source/Examples/ViewModel/RiveSlider.swift b/Example-iOS/Source/Examples/ViewModel/RiveSlider.swift index e2f5c1ab..4aab7fb9 100644 --- a/Example-iOS/Source/Examples/ViewModel/RiveSlider.swift +++ b/Example-iOS/Source/Examples/ViewModel/RiveSlider.swift @@ -21,11 +21,11 @@ class RiveSlider: RiveViewModel { super.init(fileName: "riveslider", stateMachineName: "Slide", fit: .scaleDown) } - func touchBegan(onArtboard artboard: RiveArtboard?, atLocation location: CGPoint) { + @objc func touchBegan(onArtboard artboard: RiveArtboard?, atLocation location: CGPoint) { touchMoved(onArtboard: artboard, atLocation: location) } - func touchMoved(onArtboard artboard: RiveArtboard?, atLocation location: CGPoint) { + @objc func touchMoved(onArtboard artboard: RiveArtboard?, atLocation location: CGPoint) { progress = Double(location.x / riveView!.frame.width) * 100 } }