ios - Cancel auto triggering value changed event for UISwitch -
is possible cancel auto triggering value changed event uiswitch? have action of touch inside event uiswitch, wanna background job first , when job done, manually turn switch on instead of turns on after touch background job isn't done yet.
you can not add target action .valuechanged event. switching in you're background task completion handler.
dispatch_async(dispatch_get_global_queue(dispatch_queue_priority_background, 0), { println("this run on background queue") dispatch_async(dispatch_get_main_queue(), { aswitch.value = true }) }) edit:
sorry, understood question. meant value of switch should not change first when user presses it, right?
answer:
you can set userinteractionenabled = false switch, add uiview on top of (not subview of witch) tapgesturerecognizer. handle background events when tapped, , turn on/off switch.
Comments
Post a Comment