2016-07-18 15 views
0

ライブラリNMBottomTabBarControllerを使用しています。 (参考のために。https://github.com/priankaliz/NMBottomTabBarController)AppDelegate.hでcutomTabBarをrootViewControllerに設定するにはどうすればよいですか?

私はtabBarControllerのプロパティを宣言しました。 didFinishLaunchingWithOptions

customTabBarController = (NMBottomTabBarController *)self.window.rootViewController; 
customTabBarController.controllers = [NSArray arrayWithObjects:viewController1,viewController2,viewController3,viewController4 nil]; 
customTabBarController.delegate = self; HomeViewController *controller = [[HomeViewController alloc] initWithNibName:@"HomeViewController" bundle:nil]; 
    [self.window setRootViewController:controller]; 

下AppDelegate.mで

@property (nonatomic, strong) NMBottomTabBarController *customTabBarController; 

私はHomeVCでtableViewをしました。テーブルの下にある行がクリックされると、customTabBarControllerをrootViewControllerに設定します。私が書いたものについて

- (void)tableView:(UITableView *)tableView1 didSelectRowAtIndexPath:(NSIndexPath *)indexPath{ 
    AppDelegate *appDelegate = [UIApplication sharedApplication].delegate; 
    [appDelegate.customTabBarController selectTabAtIndex:indexPath.row]; 
    [appDelegate.window setRootViewController:appDelegate.customTabBarController.tabBarController]; 
} 

このコードは機能しません。私はtabBarCotroller画面を取得していません。 正しい方法は何ですか?

答えて

0

私はあなたの問題は、このようにそれを変更することで、このライン

[appDelegate.window setRootViewController:appDelegate.customTabBarController.tabBarController]; 

てみてだと思う:私はそれを試してみましたが、そのが動作していない

[appDelegate.window setRootViewController:appDelegate.customTabBarController]; 
+0

。 – Namita

関連する問題