我试图从一个视图控制器弹出到下一个视图控制器,并且在我的应用程序委托中将新的视图控制器添加到堆栈中时遇到了困难。有没有办法不必将新的 ViewController 添加到应用程序委托的 navController 并直接从另一个视图跳转?
所以基本上我要问的是我已经向 viewController 的 UITabButtonBar 添加了一个 NEW 按钮,我想要它这样一个按钮被点击它就会移动到 NEW 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,以便我可以从另一个导航到它。有任何想法吗?