UPGRADE YOUR SKILLS: Learn advanced Swift and SwiftUI on Hacking with Swift+! >>

Flashzilla onDelete glitching

Forums > 100 Days of SwiftUI

Anyone else discovered that the onDelete gesture in EditScreen is really hard to perform, since the system tends to cancel it if you're not doing it super fast? Seems to happen in the sample solution as well, so I doubt it's a mistake on my part.

To debug, I tried to instantiate EditCards directly from FlashzillaApp and that way it worked perfectly. So maybe being presented in a .sheet is the issue? Are there any known workarounds for that?

(Xcode 13.2, iOS 15.2 device and simulator)

3      

I have found that if the iPhone has the notch on the right (and charge port on left) then the delete does work properly, however if you flip the phone around with notch on the left then it works fine, so nothing wrong with code just a iOS bug. One for file a feedback.

(Tested on real iPhone 13 Pro Max)

3      

I've had a bit more time for debugging today. It's all the fault of ContentView's timer!

To resolve this, first make the timer a @State like this:

@State var timer = Timer.publish(every: 1, on: .main, in: .common).autoconnect()

Then add the cancellation of the timer to the +-Button that sets the variable for the EditScreen:

timer.upstream.connect().cancel()
showingEditScreen = true

Finally, create a new timer at the end of resetCards():

timer = Timer.publish(every: 1, on: .main, in: .common).autoconnect()

Now swiping to delete a Card on EditCards should work smoothly.

3      

Hacking with Swift is sponsored by RevenueCat

SPONSORED Take the pain out of configuring and testing your paywalls. RevenueCat's Paywalls allow you to remotely configure your entire paywall view without any code changes or app updates.

Learn more here

Sponsor Hacking with Swift and reach the world's largest Swift community!

Archived topic

This topic has been closed due to inactivity, so you can't reply. Please create a new topic if you need to.

All interactions here are governed by our code of conduct.

 
Unknown user

You are not logged in

Log in or create account
 

Link copied to your pasteboard.