UISwitch setOn(:, animated:) does not work as document

前端 未结 3 958
失恋的感觉
失恋的感觉 2021-02-08 00:42

As Apple\'s document write, UISwitch\'s function setOn(on: Bool, animated: Bool) does not send action. It works fine before iOS 10, but it will send ac

3条回答
  •  面向向阳花
    2021-02-08 00:55

    The following solution resolves that issue. You should dispatch_async only if trying to call [UISwitch setOn:] within the action callback of that switch itself.

    dispatch_async(dispatch_get_main_queue(), ^{
    
        [switch setOn:YES animated:YES];
    });
    

提交回复
热议问题