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?
ich damit versucht, aber es funktioniert nicht. – Namita