Passing an IBaction to another ViewController

百般思念 提交于 2019-12-12 01:16:38

问题


I have an IBAction button in one UIViewController that I want to perform an action in another UIViewController. How do I do this?


回答1:


Declare a method in the second UIViewController and call from the IBAction in the first controller.

Something like this:

-(IBAction)myMethodFromFirstController{

SecondController *secondController = [[SecondController alloc] init];
[secondController method];

}



来源:https://stackoverflow.com/questions/12763470/passing-an-ibaction-to-another-viewcontroller

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!