How to click a button programmatically?

前端 未结 2 1145
梦毁少年i
梦毁少年i 2020-12-23 17:17

I have 2 view controllers which should be swapped according to userinput. So, I want to switch the views programatically based on the input I get from a text file.



        
2条回答
  •  南笙
    南笙 (楼主)
    2020-12-23 17:32

    To fire an event programmatically you need to call sendActionsForControlEvent

    button.sendActionsForControlEvents(.TouchUpInside)
    

    --

    Swift 3

    button.sendActions(for: .touchUpInside)
    

提交回复
热议问题