Ios ViewDeck在设置中央控制器时删除导航栏
我目前正在将ViewDeck与故事板一起使用,并在应用程序didFinishLaunchingWithOptions中进行以下设置:Ios ViewDeck在设置中央控制器时删除导航栏,ios,viewdeck,iiviewdeckcontroller,Ios,Viewdeck,Iiviewdeckcontroller,我目前正在将ViewDeck与故事板一起使用,并在应用程序didFinishLaunchingWithOptions中进行以下设置: //View Deck Setup UIStoryboard* mainStoryboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle: nil]; UIViewController* menuController = [mainStoryboard instantiateViewCon
//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];
}
我做错了什么 解决方案是删除AppDelegate和TabBar之间的任何“deck构造函数”类。当您需要设置或更改甲板结构时,我会为每个结构创建几个方法。例如,如果希望Deck在左侧有“leftView”视图控制器,在右侧有“rightView”,在中间有“tabBarHome”,请在应用程序委托中创建如下方法:
-(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]委托])lanzarHome]代码>
最重要的一点是,创建更改或初始化AppDelegate的Deck结构的方法,并且在delegate和中心TabBar之间永远不会有另一个类或viewController
我希望这个答案能解决你的问题。对我来说,找到这个问题是一项非常艰苦的工作。你解决了这个问题吗?我也有同样的问题…@Camacho我还没有找到解决方案。请在我的答案中找到解决方案。我希望这个答案能在你的项目中解决这个问题!感谢您分享此解决方案!我真的很感激。