UITapGestureRecognizer Programmatically trigger a tap in my view

前端 未结 8 1099
耶瑟儿~
耶瑟儿~ 2020-12-09 10:05

Edit: Updated to make question more obvious

Edit 2: Made question more accurate to my real-world problem. I\'m actually looking to take a

8条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-09 10:40

    There is a much simpler way to trigger a touch for a UITapGestureRecognizer in a unit test using a single line. Assuming you have a var that holds a reference to the tap gesture recognizer all you need is the following:

    singleTapGestureRecognizer?.state = .ended
    

提交回复
热议问题