Post

Replies

Boosts

Views

Activity

SwiftUI View gesture prevents seperate UIViewController touch events
I have a UIViewRepresentable inside my ContentView as well as other SwiftUI views.When the UIViewRepresentable is touched or any SwiftUI view is receiving a gesture independently, the views respond as expected.While I am touching the UIViewRepresentable, I can still still adjust the SwiftUI views (they still accept gestures).HOWEVER, while I am doing a gesture on a SwiftUI, I cannot receive touch events on my UIViewRepresentable. I need to be able to do this.There is no overlap between any of the views (they are not graphically blocking each other).I can adjust multiple SwiftUI views at the same time, why can't I also adjust a UIViewRepresentable at the same time?My UIViewRepresentable is a musical keyboard. My SwiftUI views adjust the sound played. I need to be able to interact with both at the same time regardless of which was pressed first.
3
2
2.6k
May ’20
ForEach Breaks Data Binding
Using a ForEach loop breaks my data binding to an object in an array. I can create my view using the index of zero - array[0] - and it responds to the databinding appropriately. If I wrap it with a ForEach but do not change the index of zero to an iterator - array[0] NOT array[index], it still creates the view, but now the data binding does not work. Same exact code, just wrapped in a ForEach loop that should only loop once (the array only has one object inside).// Does data bind correctly - UI is updated if(self.noise.twoControlEffects[0].isDisplayed){ TwoControlTemplate(title: "Low Pass Filter", isBypassed: self.$noise.twoControlEffects[0].isBypassed, knobModel1: self.$noise.twoControlEffects[0].control1, knobModel2: self.$noise.twoControlEffects[0].control2) } // Does not update UI ForEach(noise.twoControlEffects.indices){ index in if(self.noise.twoControlEffects[0].isDisplayed){ TwoControlTemplate(title: "Low Pass Filter", isBypassed: self.$noise.twoControlEffects[0].isBypassed, knobModel1: self.$noise.twoControlEffects[0].control1, knobModel2: self.$noise.twoControlEffects[0].control2) } }I tried it with array[index] as well, but then did the above once it was not working.// Does not update UI ForEach(noise.twoControlEffects.indices){ index in if(self.noise.twoControlEffects[index].isDisplayed){ Spacer() TwoControlTemplate(title: "Low Pass Filter", isBypassed: self.$noise.twoControlEffects[index].isBypassed, knobModel1: self.$noise.twoControlEffects[index].control1, knobModel2: self.$noise.twoControlEffects[index].control2) } }What does the ForEach loop do that breaks databinding? How can I create and update views using an array of objects?
11
0
8.6k
Apr ’20