iOS-tabbar控制从首页内容跳转到第三个Controlle
2017-09-30 本文已影响982人
WuNai
拿到tabbar 单例,让当前选中变成 要跳转的controller个数
两种方法:
第一种:
AppDelegate *delegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
JLTabBarController *tab = (JLTabBarController *)delegate.window.rootViewController;
tab.selectedIndex = 2;
第二种:
JLTabBarController *tabbar = [[JLTabBarController alloc] init];
UIWindow *keyWindow = [[UIApplication sharedApplication] keyWindow];
keyWindow.rootViewController = tabbar;
tabbar.selectedIndex = 2;