我使用[self.navigationController.viewControllers objectAtIndex:2]
。所以我需要在NSArray
中设置我的viewcontroller。但我试过下面的方法,然后我得到错误。我知道我没有2的数组。那么,我如何在数组中设置viewcontroller并将其作为rootviewcontroller。
ARimageViewController *arimage = [[ARimageViewController alloc] init];
UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:arimage];
SampleViewController *sample = [[SampleViewController alloc] init];
UINavigationController *nav1 = [[UINavigationController alloc] initWithRootViewController:sample];
SettingsViewController *settings = [[SettingsViewController alloc] init];
UINavigationController *nav2 = [[UINavigationController alloc] initWithRootViewController:settings];
NSArray* controllers = [NSArray arrayWithObjects:nav,nav1,nav2, nil];
self.window.rootViewController = nav;
self.window.rootViewController = nav1;
self.window.rootViewController = nav2;
PushViewcontroller:
SettingViewcontroller:
SettingsViewController *set=[[SettingsViewController alloc]init];
[self.navigationController pushViewController:set animated:YES];
返回pushviewcontroller:
Class vcClass = NSClassFromString(self.appViewControllerClassName);
id vc = [[vcClass alloc] initWithNibName:nil bundle:nil];
[self.navigationController pushViewController:vc animated:YES];