我正试图从一个viewController弹出到另一个viewController,我很难将新的ViewController添加到我的app委托中的堆栈。有没有办法不必将新的ViewController添加到app delegate的navController,只是从另一个视图直接跳转?
所以基本上我要问的是我在viewController的UITabButtonBar中添加了一个新按钮 我希望它能点击一个按钮,然后移动到新的viewController。
这是应用程序代表的样子:
-(void)navigate{
//HomeViewController *home=[[HomeViewController alloc]init];
MoreViewController *more = [[MoreViewController alloc]init];
InBoxViewController *inbox=[[InBoxViewController alloc]init];
// Add the detail view controller to the stack, but keep the root view
// controller.
UIViewController *root = self.navigationController.topViewController;
NSMutableArray *viewsArray = [self.navigationController.viewControllers mutableCopy];
self.navigationController.navigationItem.hidesBackButton=YES;
if ([root isKindOfClass:[MoreViewController class]]) {
[[NSNotificationCenter defaultCenter] postNotificationName:@"hide" object:nil];
[self.navigationController pushViewController:inbox animated:YES];
}
else if([root isKindOfClass:[HomeViewController class]]){
[viewsArray addObject:more];
[viewsArray addObject:inbox];
[self.navigationController setViewControllers:viewsArray animated:YES];
}
else if([root isKindOfClass:[InBoxViewController class]]){
[[NSNotificationCenter defaultCenter] postNotificationName:@"getMails" object:nil];
}
else if([root isKindOfClass:[MessageViewController class]]){
[self.navigationController popViewControllerAnimated:YES];
}
else if([root isKindOfClass:[ReplyViewController class]]){
[self.navigationController popToViewController:[viewsArray objectAtIndex:(viewsArray.count-3)] animated:YES];
}
else if([root isKindOfClass:[RegistrationViewController class]]||[root isKindOfClass:[ChangePasswordViewController class]]||[root isKindOfClass:[InfoViewController class]]||[root isKindOfClass:[ContactUsViewController class]]||[root isKindOfClass:[BuydealsViewController class]]||[root isKindOfClass:[FindThingsActivityViewController class]]||[root isKindOfClass:[FindThingsToDoViewController class]]||[root isKindOfClass:[ActivityViewController class]]||[root isKindOfClass:[AskMeMoreViewController class]]||[root isKindOfClass:[MyDealsView class]]||[root isKindOfClass:[InviteNewPartnerViewController class]]||[root isKindOfClass:[ContactsViewController class]]||[root isKindOfClass:[AddYourOwnActivityViewController class]]||[root isKindOfClass:[AddActivityViewController class]]||[root isKindOfClass:[MapViewController class]]){
for (int p=0; p<viewsArray.count; p++) {
if (p>1) {
[viewsArray removeObjectAtIndex:p];
p--;
}
}
inbox.navigationItem.hidesBackButton = YES;
[viewsArray addObject:more];
[viewsArray addObject:inbox];
[self.navigationController setViewControllers:viewsArray animated:YES];
[viewsArray removeObject:root];
[self.navigationController setViewControllers:viewsArray animated:YES];
}
}
我想添加一个名为“mapViewController”的新ViewController,以便我可以从另一个导航到它。有什么想法吗?