iOS界面跳转--移去中间的VC(push)

假设NavigationController有ABC三个ViewController,
A push B, B push C
要求C返回的时候直接返回A,即移除B。
(popToRoot不予考虑,A之前可能还有其他的)

方案一:pop后再push

UINavigationController *navController = self.navigationController; [navController popViewControllerAnimated:NO]; [navController pushViewController:vc animated:YES];

缺点:动画过程中会看到B被A替换,然后C在右边滑入

方案二:修改viewControllers数组

NSMutableArray* navArray = [[NSMutableArray alloc] initWithArray:self.navigationController.viewControllers]; [navArray replaceObjectAtIndex:[navArray count]-1 withObject:nextViewController]; [self.navigationController setViewControllers:navArray animated:YES];

看不到B被A替换的过程,用户完全无感知。666

你可能感兴趣的:(iOS界面跳转--移去中间的VC(push))