将IBaction传递给另一个ViewController [英] Passing an IBaction to another ViewController

查看:115
本文介绍了将IBaction传递给另一个ViewController的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在一个UIViewController中有一个IBAction按钮,我想在另一个UIViewController中执行一个动作。我该怎么做?

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

推荐答案

在第二个UIViewController中声明一个方法,并从第一个控制器中的IBAction调用。

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

这样的事情:

-(IBAction)myMethodFromFirstController{

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

}

这篇关于将IBaction传递给另一个ViewController的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆