在实际开发时,例如支付完毕或是点击推送消息后,经常需要进行页面的跳转,以下我总结了三类情况:
根据指定的index返回controller
NSArray * ctrlArray = self.navigationController.viewControllers;
[self.navigationController popToViewController:[ctrlArray objectAtIndex:1] animated:YES];
返回指定的tabbar
UITabBarController *tabVC = (UITabBarController *)[UIApplication sharedApplication].keyWindow.rootViewController;
UINavigationController *navVC = tabVC.viewControllers[3];
navVC.viewControllers[0].tabBarController.selectedIndex = 3;
返回某个tabbar的源controller
UITabBarController *tabVC = (UITabBarController *)[UIApplication sharedApplication].keyWindow.rootViewController;
UINavigationController *navVC = tabVC.viewControllers[0];
[navVC popToRootViewControllerAnimated:YES];