如何以编程方式单击按钮?

发布于 2021-01-29 15:08:19

我有2个视图控制器,应根据用户输入进行交换。因此,我想根据从文本文件获得的输入以编程方式切换视图。

Algorithm : 
if(input == 1)
{
    Go to View Controller 1
}
else if(input ==2)
{
    Go to View Controller 2 
}

关于如何以编程方式单击按钮或使用输入加载特定ViewController的任何帮助?

关注者
0
被浏览
96
1 个回答
  • 面试哥
    面试哥 2021-01-29
    为面试而生,有面试问题,就找面试哥。

    要以编程方式触发事件,您需要致电 sendActionsForControlEvent

    button.sendActionsForControlEvents(.TouchUpInside)
    

    -

    迅捷3

    button.sendActions(for: .touchUpInside)
    


知识点
面圈网VIP题库

面圈网VIP题库全新上线,海量真题题库资源。 90大类考试,超10万份考试真题开放下载啦

去下载看看