Gezinmeyi atla
Remember, you can simply disable the gesture recognizer in SwiftUI using a ternary operator.
0:00 / 0:24

Remember, you can simply disable the gesture recognizer in SwiftUI using a ternary operator.

Mike Mikina

@mikemikina1,2 B takipçi

X profili
224 beğeniİndirOrijinal gönderi

22.491 görüntüleme

Remember, you can simply disable the gesture recognizer in SwiftUI using a ternary operator. You may need to refactor your gesture recognizer, but it’s quite simple ➡️

9 Yorum

Yorumlar X (Twitter) üzerindeki orijinal gönderiden alınmıştır

  • Mike Mikina profil fotoğrafı

    @mikemikina

    A follow up! It turns out that the documentation includes gesture(_:isEnabled:), so you can simply pass a boolean value there. Kudos to @harlanhaskins!

    7 beğeni

  • Harlan Haskins profil fotoğrafı

    @harlanhaskins

    .gesture(…) also has a variant that takes an isEnabled parameter.

    3 beğeni

  • Mike Mikina profil fotoğrafı

    @mikemikina

    Wait, what?! How did I miss it? I swear I was looking for it in the documentation the other day 😄 Thanks for sharing! 🙌

    1 beğeni

  • Raul Menezes profil fotoğrafı

    @rmenezes89

    You can achieve the same result by using `.disabled(!isActive)` so you don’t need to touch your gestures and keep your code as simple as it can be.

    1 beğeni

  • Mike Mikina profil fotoğrafı

    @mikemikina

    In this example, it will certainly work the same way. However, if you have another gesture recognizer or the view has additional interactions, it will not work.

  • Pavan profil fotoğrafı

    @pavm035

    Oh I didn’t know this, good one!

    1 beğeni

  • Moneky profil fotoğrafı

    @wealthybaboon

    Is this Swift for newbies?

  • Rob Jonson profil fotoğrafı

    @ConfusedVorlon

    How is nil valid as "some Gesture" ??

  • Mike Mikina profil fotoğrafı

    @mikemikina

    It's because Optional conditionally conforms to Gesture. You can read more about it here: