【发布时间】:2014-07-17 23:39:24
【问题描述】:
我有一个名为 sendDataToMotor 的函数。它在我的第一个视图控制器类中。我有另一个名为 SecondViewController 的视图控制器。我需要从 Second View Controller.m 类中调用这个函数。我尝试声明该属性:
@property(nonatomic,assign)UIViewController* firstController;
在我的 SecondViewController.h 类中。此外,我在 SecondViewController.m 类的 viewDidLoad 部分中编写了下面的代码(我希望调用该函数)。
secondViewController = [[SecondViewController alloc] initWithNibName:@"secondViewController" bundle:nil];
secondViewController.firstController = self;
[self.firstController performSelector:@selector(sendDataToMotor)];
但是,由于未声明的标识符问题,我在该代码 (secondViewController) 中的第一个单词出现错误。此外,第二行 (secondViewController.firstController = self) 出现错误,因为 secondViewController 的名称类型未知。
总之,我不在乎您是否使用上面的代码来回答我的问题:这只是我在网上找到的尝试实现的东西。但是,我正在寻找从另一个视图控制器调用函数的最简单方法。
【问题讨论】:
标签: ios objective-c uiviewcontroller