带有UITabBarController的MMDrawerController在中心视图的顶部显示黑色间隙

时间:2015-11-25 12:42:05

标签: ios objective-c uitabbarcontroller mmdrawercontroller

我在左侧打开一个带MMDrawerController的UITabBarController。 所以从我的代表didFinishLaunchingWithOptions我正在制作一个MMDrawerController,其centerNav是TabBarController,leftNav是一个带导航控制器的ViewController。正如预期的那样,tabbar随mmdrawer一起出现,但LandingTabBarController顶部有一个黑色间隙。如果我直接打开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]; 
}

enter image description here

调试器的屏幕截图

enter image description here

0 个答案:

没有答案