我正在开发iOS应用程序,其中我有TabBar的侧边菜单,
我已将我的sidemenu container viewController
作为我应用的IntitalViewController确定。
这是我的代码:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:[NSBundle mainBundle]];
MFSideMenuContainerViewController *container = (MFSideMenuContainerViewController *)self.window.rootViewController;
UINavigationController *navigationController = [storyboard instantiateViewControllerWithIdentifier:@"navigationController"];
UIViewController *leftSideMenuViewController = [storyboard instantiateViewControllerWithIdentifier:@"leftSideMenuViewController"];
[container setLeftMenuViewController:leftSideMenuViewController];
[container setCenterViewController:navigationController];
return YES;
}
这是我的故事设计:
当我运行我的应用程序时,我看到一个没有错误的黑屏
我在哪里犯了错误,请帮忙
感谢adavnnce !!
答案 0 :(得分:1)
尝试这个(看到你的代码后):
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:[NSBundle mainBundle]];
self.window.rootViewController=[[MFSideMenuContainerViewController alloc]init];
// Override point for customization after application launch.
MFSideMenuContainerViewController *container = (MFSideMenuContainerViewController *)self.window.rootViewController;
UITabBarController *tabController = [storyboard instantiateViewControllerWithIdentifier:@"tabBarController"];
UIViewController *leftSideMenuViewController = [storyboard instantiateViewControllerWithIdentifier:@"leftSideMenuViewController"];
[container setLeftMenuViewController:leftSideMenuViewController];
[container setCenterViewController:tabController];
[self.window makeKeyAndVisible];
return YES;
}
同时提供相应的ID来查看故事板中的控制器(对于tabBar,导航) 并且不要忘记给根视图控制器进行导航 控制器。