iOS - 远程类中的调用方法

时间:2014-03-10 20:26:25

标签: ios objective-c class

我正在开发一个应用程序,我需要在类ViewController的指示下调用类NewNoteController中的函数。

我以这种方式在不同的视图控制器之间切换:

NSString * storyboardName = @"Main";
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:storyboardName bundle: nil];
UIViewController * vc = [storyboard instantiateViewControllerWithIdentifier:@"ViewController"];
[self presentViewController:vc animated:NO completion:nil];

问题在于,当我切换到ViewController时,不会调用(void)viewDidLoad。我应该使用ViewController.mNewNoteController.m调用方法?

1 个答案:

答案 0 :(得分:3)

尝试使用以下代码..

NSString * storyboardName = @"Main";
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:storyboardName bundle: nil];
ViewController * vc = [storyboard instantiateViewControllerWithIdentifier:@"ViewController"];
[vc yourmethodname];
[self.navigationController pushViewController:vc animated:YES];

希望它可以帮助你..