1

This is my code:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    self.window = [[UIWindow alloc]initWithFrame:[UIScreen mainScreen].bounds];
    self.window.backgroundColor = [UIColor whiteColor];
    //侧滑菜单
    YZTabBarController *tabBarController = [[YZTabBarController alloc]init];
    YZPesonalCenterViewController *personalVC = [[YZPesonalCenterViewController alloc]init];
    MFSideMenuContainerViewController *container = [MFSideMenuContainerViewController containerWithCenterViewController:tabBarController leftMenuViewController:personalVC rightMenuViewController:nil];
    self.window.rootViewController = container;//[[YZTabBarController alloc] init];
    [self.window makeKeyAndVisible];
    NSShadow *titleShadow = [[NSShadow alloc] init];
    titleShadow.shadowOffset = CGSizeMake(0, 0);
    titleShadow.shadowColor = [UIColor lightGrayColor];
    NSDictionary *titleAttrs = [NSDictionary dictionaryWithObjectsAndKeys:[UIColor whiteColor], NSForegroundColorAttributeName, titleShadow, NSShadowAttributeName, [UIFont boldSystemFontOfSize:18.0], NSFontAttributeName, nil];
    [[UINavigationBar appearance] setTitleTextAttributes:titleAttrs];
    [[UINavigationBar appearance] setTintColor:[UIColor whiteColor]];
    [[UINavigationBar appearance] setBackgroundImage:[UIImage imageNamed:@"navi_back"] forBarMetrics:UIBarMetricsDefault];

    // 键盘设置
    IQKeyboardManager *sharedManager = [IQKeyboardManager sharedManager];
    sharedManager.shouldResignOnTouchOutside = YES;
    sharedManager.enableAutoToolbar = YES;

    //设置状态栏样式
    [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];

    return YES;
}

and the error is:

app due to uncaught exception 'NSInvalidArgumentException',
reason: '-[MFSideMenuContainerViewController tabBar]:
unrecognized selector sent to instance 0x7ff6fb16f780'

J.Ming
  • 11
  • 3
  • Can you post the whole didFinishLaunchingWithOptions method – ZHZ Dec 07 '15 at 03:31
  • I had post all my didFinishLaunchingWithOptions method,can you help me? thank you! – J.Ming Dec 07 '15 at 03:53
  • It seems no problem in didFinishLaunchingWithOptions. You should find the call of tabBar otherWhere. Because your rootViewController is MFSideMenuContainerViewController instead of UITabController, you can not use tabBar any more. This makes the error . – ZHZ Dec 07 '15 at 04:08
  • Sorry,I can not understand what you say,if I don't use tabBar,how can I use UITabBarController? – J.Ming Dec 07 '15 at 04:50
  • I mean you can not get tabBar from your rootviewController directly. – ZHZ Dec 09 '15 at 00:23

0 Answers0