上图为启动app后进入的页面app
下图为子界面
spa
如今有这样一个需求,须要在子界面点击查看报告时跳回到tabbar界面,而且设定tabbar选定为第二个界面,刚开始为这个问题纠结了很长时间,这该怎么跳?present和push显然是不行的,那么应该怎么办呢?code
其实和简单,只要获取到定义的tabbar,而后设定window的rootController为tabbar,同时设定tabbar的selected就能够了,代码以下:it
ViewController *VC = [[ViewController alloc] init]; VC.selectedIndex = 0; UIWindow *window = [UIApplication sharedApplication].keyWindow; window.rootViewController = VC;
其中VC为tabbar。
io