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

前端 未结 3 914
失恋的感觉
失恋的感觉 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 01:04

    DispatchQueue.main.async {
        sender.setOn(flag, animated: animated)
    }
    

    it works for me in Xcode 8.

    but call UISwitch.setOn(_:animated:) directly on main thread doesn't work.

    Update

    thanks to @codiction:

    UISwitch.setOn(_:animated:) can be called direclty on main thread, but can't be called directly in UISwitch ValueChanged action on iOS 10.

提交回复
热议问题