【发布时间】:2014-08-18 11:52:44
【问题描述】:
这是我的层次结构:
A - B - C - D (tabs)
| | | |
| | | |
----------------> AddEventViewController (can be called from any tabs)
|
|
|----> SuggestFeedController (can be accessed from B only)
假设我当前在 D 选项卡中,我调用了 AddEventViewController。 在此之后,我想将用户重定向到“SuggestFeedController”,但我想保留层次结构,这意味着按下后退按钮应该重定向到 B 而不是 AddEventViewController 也不是 D。
我尝试做的事情如下:
UITabBarController *tabbarController = ((UITabBarController *)appDelegate.window.rootViewController);
[tabbarController setSelectedIndex:1]; // Selecting the B tab
UIStoryboard* storyboard= appDelegate.window.rootViewController.storyboard;
UICategoryFeedController *cfvC = [storyboard instantiateViewControllerWithIdentifier:@"UICategoryFeedController"]; // Instantiating B view Controller
SuggestFeed *suggestFeed = [storyboard instantiateViewControllerWithIdentifier:@"SuggestFeed"];
NSArray *viewControllers = [[NSArray alloc] initWithObjects:cfvC, suggestFeed, nil]; // Trying to create my own navigation stack, B first, then Suggest Feed
[self.navigationController pushViewController:suggestFeed animated:NO]; // Some guys on internet do the push, even if I don't think it's necessary because it's already in the stack
NSLog(@"nav stack1 : %@", self.navigationController.viewControllers );
/* returns stack1 : (
"<D: 0xa627990>",
"<AddEventViewController: 0x108cb7e0>",
"<SuggestFeed: 0x123735f0>"
) */
[self.navigationController setViewControllers:viewControllers animated:NO];
NSLog(@"nav stack2 : %@", self.navigationController.viewControllers );
/* returns stack2 : (null) */
我做错了吗? (愚蠢的问题)
为什么 stack2 是 nil,而我已经从我的数组中设置了 viewControllers?
如果你能带来一些帮助,在此先感谢:-)
【问题讨论】:
标签: ios objective-c uinavigationcontroller pushviewcontroller