Post

Replies

Boosts

Views

Activity

GeometryReader Stops View Updating
I have a number of Observable Object classes and for each, I define a "resultsView" variable that summarises key data from the class in an AnyView. This variable can then be embedded in a View struct. Typically, I use a protocol to allow the View struct to display the "resultsView" of a number of data object classes. This works fine and redraws the view when the Observable Object updates. I have now added a GeometryReader within this variable in the class. Now, any data items within the Geometry Reader no longer update when the view is rebuilt, following a change in the @Published Value in the Observable Object. Below is a test View demonstrating this. It is a simple button incrementing the published value on the object. The View body also includes the testObject.resultsView which is an AnyView type summarising the results from the class. struct ContentView: View {   @ObservedObject var testObject: TEST = TEST()           var body: some View {     VStack {       Text("Current Value From View \(testObject.testValue)")       Button<Text>(action: {self.testObject.testValue += 1}, label: { Text("Add One Button")})       testObject.resultView     }   } } struct ContentView_Previews: PreviewProvider {   static var previews: some View {     ContentView()   } } This is my class, including the resultsView variable. class TEST: ObservableObject {   @Published var testValue: Double = 0   var resultView: AnyView {     AnyView(       VStack{       Spacer()       Text("Text From Object, Outside of GeometryReader")         Text("Value \(self.testValue.description)")       GeometryReader {         geom in         VStack {         Text("Text From Object Inside Geom Reader")         Text(self.testValue.description).frame(width: geom.size.width / 2, height: geom.size.height / 2)         }.background(Color.secondary)         }}.background(Color.yellow)     )   } // End of resultView } //End of Class } When I run this all values update on the button press, except the one that is returned in the GeometryReader section of the AnyView variable. It seems anything I put in the Geometry reader section no longer updates. I have also tried passing as a () -> AnyView closure and using a @ViewBuilder function with the same result. It is being called to update as the first return of the value is updating but not the value from within the GeometryReader. Any Ideas?
3
0
2.7k
Sep ’20
TestFlight In-App Purchase and iCloud Key Values
I am trying to test an app with InApp purchase in TestFlight. I have also been testing in the Sandbox. In either environment I can not see purchases made on one machine, on a second machine. In TestFlight I am using my real Apple ID in the Test Flight app. In the Sandbox I am using a Sandbox user set up in AppStoreConnect. Should purchases be recognised on two machines? I am trying to test functionality or purchasing a non-consumable on one machine and then also having access to it on a second. This is just extra functionality enabled on time only. Should I be able to see purchases across the machines in SandBox or TestFlight or are they just simulating locally? I have the same problem with Key values in iCloud which I can not see between two machines with the same user.
1
0
373
Aug ’23