Listener not triggering in runtime (IOS)
I’ve created a animating Dollhouse and when clicking on a “room” it Zooms in. I added a click listener on a group (and also tried a rectangle inside the group) and it works in the editor, but when exporting it and running it in IOS, it doesn’t do anything.
The swift file looks like this:
import RiveRuntime
import SwiftUI
/ MARK: - Root (example)
struct ContentView: View {
var body: some View {
DollhouseView()
}
}
// MARK: - Dollhouse View
struct DollhouseView: View {
// Make sure you have an asset named "dollhouse" in Assets.xcassets
private let riveView: RiveViewModel
var viewModelInstance: RiveDataBindingViewModel.Instance!
init() {
let riveView = RiveViewModel(fileName: "dollhouse")
riveView.fit = .layout
riveView.layoutScaleFactor = RiveViewModel.layoutScaleFactorAutomatic
riveView.alignment = .center
riveView.riveModel?.enableAutoBind { instance in
// Get the string property
let stringProperty = instance.stringProperty(fromPath: "zoomed_room")!
// Add a listener
let listener = stringProperty.addListener { newValue in
print(newValue)
}
}
self.riveView = riveView
}
var body: some View {
ZStack(alignment: .topLeading) {
ZStack(alignment: .top) {
GeometryReader { geo in
riveView
.view()
.frame(width: geo.size.width, height: geo.size.height)
.scaledToFill()
}
.ignoresSafeArea()
}
}
}
}
// MARK: - Previews
#Preview {
ContentView()
}
I’ve also added a swift runtime listener on the databinding and this also does not log anything. What am I missing?