Post

Replies

Boosts

Views

Activity

Reply to why do I get this error
The error message should be self explanatory? In SwiftUI, you can not just write arbitrary code, when a View is expected. Remember that you are declaring a UI. Try replacing your "for" loop with this SwiftUI code: ForEach(cities, id: \.self) { city in Text("City: \(city)") }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Jan ’22
Reply to SwiftUI opacity animation fails in Gesture's onEnded method
Interestingly, if I add another modifier to the first Rectangle, the fade-in works! Rectangle() .fill( fade ? .red : .blue) .frame(width: 100, height: 100, alignment: .center) .opacity(fade ? 0 : 1) SwiftUI can only animate viewModifiers for Views that are already on-screen. I think what is happening is that when the opacity is set to 0, SwiftUI removes that view from the screen... ...so it's re-appearance (on setting opacity to 1) is not animated. As a test, try fading out, but not right to 0: .opacity(fade ? 0.1 : 1) This seems to work.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Jan ’22
Reply to Problems updating a variable
You are declaring "tagUID" in a class, so you should not be using the @State property wrapper (which is for SwiftUI). Try removing the "@State"... just use: var tagUID = "UID" Or since your NFCReader is an ObservableObject, you may mean: @Published var tagUID = "UID"
Jan ’22
Reply to Swift: How to add 47 Bool filter to json List
Have you considered rewriting it as a method that tests each Bool individually, and returns the overall Bool result? Perhaps something like... func include() -> Bool { if !filters.showhjertestarterOnly || havneplan.hjertestarter { return true } if !filters.showpaabroerneOnly || havneplan.paabroerne { return true } /// And so on, through your 47 Bools... return false }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Jan ’22
Reply to Swift: How to add 47 Bool filter to json List
I don't know how to solve your issue, but perhaps this clue will help... In SwiftUI, a ViewBuilder is limited to a maximum of 10 Views. It looks like there may be a similar limit to filters? I found your code a bit confusing (json doesn't seem to have any relevance), but I suspect there may be a more elegant solution. Would you like to post a bit more about what you are trying to achieve, and how (and why)?
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Jan ’22