2016-07-18 9 views
0

Ich verwende die Bibliothek NMBottomTabBarController. (Für Ref. https://github.com/priankaliz/NMBottomTabBarController)Wie setze ich CutomTabBar auf rootViewController?

In AppDelegate.h Ich habe die Eigenschaft für TabBarController deklariert.

@property (nonatomic, strong) NMBottomTabBarController *customTabBarController; 

In AppDelegate.m unter 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]; 

I tableView in HomeVC haben. Wenn auf die Zeile unter der Tabelle geklickt wird, möchte ich, dass customTabBarController auf rootViewController gesetzt wird. Dafür habe ich geschrieben

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

Dieser Code funktioniert nicht. Ich bekomme den tabBarCotroller-Bildschirm nicht. Was ist der richtige Weg?

Antwort

0

denke ich, Ihr Problem mit dieser Linie ist

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

versuchen, es wie folgt zu ändern:

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

ich damit versucht, aber es funktioniert nicht. – Namita

Verwandte Themen