Post

Replies

Boosts

Views

Activity

Reply to Why is a Class faster in SwiftUI than a Struct? (with example)
did you ever found a workaround this? i am experiencing the same performance degradation on tvOS when trying to 'swipe' and update really fast a timestamp text, i tried using a @State / @StateObject / @Binding / @Observable (which is a class) and nothing got me even close, if i get rid of the text and only update a location indicator (moving a rectangle + image + another rectangle as a background filler, using offset) - that works perfect, but as soon as i insert Text everything is back to choppy
Sep ’21
Reply to tvos 15 - Siri Remote not returning in the array: GCController.controllers()
thanks @robnotyou based on your answer i added a first call and the second call (after interaction with remote) worked on first call: import GameController struct ContentView2: View {   var body: some View {     let a = print("controllers: \(GCController.controllers())")           Button("Query controllers") {       print("controllers: \(GCController.controllers())")     }   } } i think there is some initialization missing (dam apple and it's useless docs) for now this workaround will do
Sep ’21
Reply to Detecting tap on tvOS with SwiftUI
you can detect press or long press while using focusable, like this: import SwiftUI struct TestView: View {   @State var isFocused: Bool = false       var body: some View   {     Button(action: {       print("Clicked") // simple click     }, label: {       Text("Click Me")     })           .buttonStyle(PlainButtonStyle())           .focusable(true, onFocusChange: { focused in       self.isFocused = focused     })           // long press (hold for at least half a second)     .highPriorityGesture(       LongPressGesture(minimumDuration: 0.5)         .onEnded { _ in           print("Long Pressed ...")         }     )           // click     .onLongPressGesture(minimumDuration: 0.01, perform: {       print("Single Short Click Pressed ...")     })   } }
Nov ’22