在类中添加NavigationController而不是在appdelegate中

时间:2013-03-29 05:41:30

标签: ios objective-c uinavigationcontroller

如何在任何类的viewDidLoad方法中为下一个类添加navigationcontroller,我还没有在appdelegate的开头添加它。

1 个答案:

答案 0 :(得分:2)

YourViewController *report = [[YourViewController alloc]  init]; // create Object of YourViewController

UINavigationController *navigationController = [[UINavigationController alloc]initWithRootViewController:report]; // add YourViewController as root view controller of UINavigationController

[self presentModalViewController:navigationController animated:YES];