我有两个ViewControllers这个项目。 这很简单。 在第二个窗口中,我只需要一个按钮来执行操作(链接到iTunes商店)。 我将代码添加到我的.h和.m文件中,但是无法在第二个窗口中将操作链接到我的按钮。 但我可以进入第一个...我发誓我冲浪和搜索但我找不到这样的答案。 应该很容易,不应该吗? 大家好!
I have this project with two ViewControllers. It´s very simple. In the second window I only want a button to perform an action (link to iTunes store). I´m adding the code to my .h and .m files, but it´s not possible to link the actions to my button in the second window. But I can into the first one… I swear that I surfed and searched but I can´t find an answer to something like this. Should be easy, shouldn´t it? Thanx everybody!!
最满意答案
如果在一个ViewController中创建IBAction ,则从另一个ViewController中将无法看到它。 这只是ViewControllers的本质。 如果你愿意,你可以使第二个类继承方法和变量形成另一个。 您可以通过替换来完成此操作
@interface SecondViewController: UIViewController {同
@interface SecondViewController: FirstViewController {在SecondViewController.h中
(如果出现错误,请在类的最顶部添加#import "FirstViewController.h" )
If you create an IBAction in one ViewController, it will not be visible from the other. This is just the nature of ViewControllers. If you want to, you can make the second class inherit the methods and variables form the other. You can do this by replacing
@interface SecondViewController: UIViewController {with
@interface SecondViewController: FirstViewController {in SecondViewController.h
(and if you get an error, add #import "FirstViewController.h" at the very top of the class)
更多推荐
发布评论