how to programmatically fake a touch event to a UIButton?

后端 未结 8 1761
余生分开走
余生分开走 2020-11-29 15:48

I\'m writing some unit tests and, because of the nature of this particular app, it\'s important that I get as high up the UI chain as possible. So, what I\'d l

相关标签:
8条回答
  • 2020-11-29 16:21

    An update to this answer for Swift

    buttonObj.sendActionsForControlEvents(.TouchUpInside)
    

    EDIT: Updated for Swift 3

    buttonObj.sendActions(for: .touchUpInside)
    
    0 讨论(0)
  • 2020-11-29 16:27

    Swift 3:

    self.btn.sendActions(for: .touchUpInside)
    
    0 讨论(0)
提交回复
热议问题