我正在开发一个应用程序,我需要在类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.m
从NewNoteController.m
调用方法?
答案 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];
希望它可以帮助你..