How can you recognise Siri Remote swipe gestures from SwiftUI.
I seems like it has not yet been implemented, so how can I get around that?
i have 2 answers for this question, i will answer them separately and let you guys decide which is best,
first is the apple way (which obviously doesn't work allways, there are more clicks captured then swipes):
import SwiftUI
struct SwipeTestView: View
{
var body: some View
{
Text("This can be some full screen image or what not")
.focusable() // <-- this is a must
.onMoveCommand { direction in // <-- this $#!* can't tell a move swipe from a touch (direction is of type: MoveCommandDirection)
print("Direction: \(direction)")
if direction == .left { print(">>> left swipe detected") }
if direction == .right { print(">>> right swipe detected") }
if direction == .up { print(">>> up swipe detected") }
if direction == .down { print(">>> down swipe detected") }
}
}
}
you really (and i can't emphasize this enough) have to swipe on the very edge of the Siri-remote or the iPhone Siri remote widget,
so try to swipe on these yellow areas and try not to tap you'r finger and then swipe, rather gently swipe outwards and let you'r finger get outside of the remote edge completely
Result expected:
i literally tried 100+ times before successfully captured a swipe (clearly not something for production), hopefully tvOS 15 and higher will fix this
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With