我试图从应用程序委托(delegate)调用 View Controller 中的方法,但 Xcode 显示No known class method for selector 'myMethodHere'。这是我的代码:
AppDelegate.m:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
[..]
[MainViewController myMethodHere];
[..]
return YES;
}
MainViewController.m:
-(void) myMethodHere {
[..]
}
最佳答案
我会努力
MainViewController * vc = [[MainViewController alloc]init];
[vc myMethodHere];
[vc release];
- 确保在您的应用委托(delegate)
.m
文件中导入您的 MainViewController - 确保将“myMethodHere”添加到 MainViewController
.h
文件
关于iphone - 从应用程序委托(delegate)调用 View Controller 方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8141332/