- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
//-- Notification Observer
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(HomeNotification:)name:@"HOME"object:nil];
return YES;
}
#pragma mark - Sidemenu & Home
- (void)HomeNotification:(NSNotification *) notification
{
UIStoryboard *sideMenuSB = [UIStoryboard storyboardWithName:SB_SideMenu bundle:[NSBundle mainBundle]];
SideMenuViewCntrl *sideMenuVC = [sideMenuSB instantiateViewControllerWithIdentifier:VC_SideMenu];
UIStoryboard *HomeSB = [UIStoryboard storyboardWithName:SB_Home bundle:[NSBundle mainBundle]];
HomeViewController *homeVC = [HomeSB instantiateViewControllerWithIdentifier:VC_Home];
UINavigationController *navigationController = [HomeSB instantiateViewControllerWithIdentifier:@"navigationController"];
MFSideMenuContainerViewController *container = nil;
if ([[notification name] isEqualToString:@"HOME"])
{
container = [MFSideMenuContainerViewController containerWithCenterViewController:homeVC leftMenuViewController:sideMenuVC rightMenuViewController:nil];
}
Adding view to window will call viewdidload multiple times?
[container setLeftMenuViewController:sideMenuVC];
[container setCenterViewController:navigationController];
self.window.backgroundColor = [UIColor blackColor];
self.window.rootViewController = container;
[self.window makeKeyAndVisible];
}
答案 0 :(得分:0)
我在SideMenu容器中添加了两次Home和侧面菜单视图控制器。
container = [MFSideMenuContainerViewController containerWithCenterViewController:homeVC leftMenuViewController:sideMenuVC rightMenuViewController:nil];
删除下面的代码后,现在工作正常....
[container setLeftMenuViewController:sideMenuVC];
[container setCenterViewController:navigationController];