|
I’m using a custom button type that is disabled when pressed, amongst other things. I’m able to successfully disable the buttons, but even though the dynamic shouldBeDisabled property is set back to false at a later time, the buttons remained permanently disabled. Note: Via different outputs to the console, I’m able to confirm that shouldBeDisabled is indeed being changed to false, and the buttons are not redrawn.
Why would the button successfully become disabled, but not be enabled again when I set shouldBeDisabled back to false? |
|
|
|
I apologize if this code is ugly. I'm completely-blind and just finished 100 Days of SwiftUI about a month ago. /* I was trying to keep my code sample small to keep the post short I instantiate these buttons in a parent view, where I was originally initializing every button needed and storing them in an array. I was told in some Swift Facebook groups that storing an array of these buttons in the parent view is bad practice, so I’ve track these buttons by their data instead. I’ll include the actual code this time, so I apologize for the lengthier post. First, here’s the button type:
Now, here's the class that tracks hidden button data
And finally, here's the parent view where the buttons are instantiated, and where I attempt to enable some of the buttons again.
|
SPONSORED Play is the first native iOS design tool created for designers and engineers. You can install Play for iOS and iPad today and sign up to check out the Beta of our macOS app with SwiftUI code export. We're also hiring engineers!
Sponsor Hacking with Swift and reach the world's largest Swift community!
You need to create an account or log in to reply.
All interactions here are governed by our code of conduct.
Link copied to your pasteboard.