3

我在左侧打开一个带有MMDrawerController的 UITabBarController。所以从我的代表didFinishLaunchingWithOptions那里,我正在制作一个带有 centerNav 的 MMDrawerController ,TabBarController 而 leftNav 是一个带有导航控制器的 ViewController 。因此,正如预期的那样,标签栏mmdrawerLandingTabBarController. 如果我直接打开 LandingTabBarController ,那么它来自顶部。怎么了?

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    self.window = [[UIWindow alloc] initWithFrame:UIScreen.mainScreen.bounds];
    UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
    LandingTabBarController *landingTabBarController = [[LandingTabBarController alloc]initWithManagedObjectContext:self.managedObjectContext];
    UIViewController * drawerNavController = [storyboard instantiateViewControllerWithIdentifier:@"DrawerViewController"];

    UINavigationController *centerNav = [[UINavigationController alloc]initWithRootViewController:landingTabBarController];

    UINavigationController *leftNav = [[UINavigationController alloc]initWithRootViewController:drawerNavController];


    centerNav.navigationBar.barStyle = UIStatusBarStyleLightContent;
    leftNav.navigationBar.barStyle = UIStatusBarStyleLightContent;
    _drawerController = [[MMDrawerController alloc] initWithCenterViewController:centerNav leftDrawerViewController:leftNav];

    _drawerController.openDrawerGestureModeMask = MMOpenDrawerGestureModePanningCenterView;
    _drawerController.closeDrawerGestureModeMask = MMCloseDrawerGestureModePanningCenterView;
    _drawerController.showsShadow = NO;
    //[_drawerController setDrawerVisualStateBlock:[MMDrawerVisualState slideVisualStateBlock]];
    [_drawerController setDrawerVisualStateBlock:MMDrawerSideNone];
    self.window.rootViewController = _drawerController;
   [self.window makeKeyAndVisible];
    return YES;
}

这是我的 LandingTabBarController viewDidLoad

- (void)viewDidLoad {
    [super viewDidLoad];
    NSMutableArray *tabViewControllers = [[NSMutableArray alloc] init];
    UIViewController *firstViewController = [[UIViewController alloc]init];
    [firstViewController.view setBackgroundColor:[UIColor redColor]];

    UIViewController *secondViewController = [[UIViewController alloc]init];
    [secondViewController.view setBackgroundColor:[UIColor greenColor]];

    [tabViewControllers addObject:firstViewController];
    [tabViewControllers addObject:secondViewController];
    [self setViewControllers:tabViewControllers];

    firstViewController.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"one" image:[UIImage imageNamed:@"icon_feed"] tag:1];
    secondViewController.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"two" image:[UIImage imageNamed:@"icon_apps"] tag:2]; 
}

在此处输入图像描述

调试器的屏幕截图

在此处输入图像描述

4

0 回答 0