我目前正在使用ViewDeck和Storyboard,并在application didFinishLaunchingWithOptions
中进行了以下设置:
//View Deck Setup
UIStoryboard* mainStoryboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle: nil];
UIViewController* menuController = [mainStoryboard instantiateViewControllerWithIdentifier:@"LeftSideMenu"];
UINavigationController* navigationController = (UINavigationController *) self.window.rootViewController;
self.viewDeckController = [[IIViewDeckController alloc] initWithCenterViewController:navigationController leftViewController:menuController rightViewController:nil];
self.window.rootViewController = self.viewDeckController;
但是,当我从我的MenuViewController设置新的CenterController
时,导航栏将被删除,即使加载与我之前看到的相同的中心视图控制器也是如此。
- (IBAction)viewUsers:(UIButton *)sender
{
UIStoryboard* mainStoryboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle: nil];
UIViewController* viewController = [mainStoryboard instantiateViewControllerWithIdentifier:@"middleViewController"];
[self.viewDeckController setCenterController:viewController];
[self.viewDeckController closeLeftView];
}
我做错了什么?
答案 0 :(得分:2)
解决方法是删除AppDelegate和TabBar之间的任何“deck构造函数”类。当您需要设置或更改Deck结构时,我为每个结构创建了几个方法。例如,如果你想让Deck在左侧有“leftView”视图控制器,在右边有“rightView”,在中心有“tabBarHome”,在App Delegate中创建一个这样的方法:
-(void) lanzarHome{
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
IIViewDeckController* deckController =[[IIViewDeckController alloc] initWithCenterViewController:[storyboard instantiateViewControllerWithIdentifier:@"tabBarHome"]
leftViewController:[storyboard instantiateViewControllerWithIdentifier:@"leftView"]
rightViewController:[storyboard instantiateViewControllerWithIdentifier:@"rightView"]];
deckController.leftSize = 100;
self.window.rootViewController = deckController;
[self.window makeKeyAndVisible];
}
现在,您必须使用以下句子从viewController调用此方法:
[((VKAppDelegate*) [[UIApplication sharedApplication] delegate]) lanzarHome];
最重要的想法是创建从AppDelegate更改或修改Deck结构的方法,从不在委托和中心TabBar之间有另一个类或viewController。
我希望这个答案可以解决你的问题。对我来说,找到这个问题是一项非常艰苦的工作。