場景:我從A到B,邏輯操做後跳到C,可是想到c返回的話會跳到B,可是不須要到B而直接到A,因此我從B到C的時候我想把self.navigationController裏的B移除。c在2個地方用到。因此點擊左上角返回按鈕,就須要pop。swift
遇到的坑:學習
原來本身理解錯了setViewControllers方法,set了以後就已經入棧了。因此不須要再次push一次。code
修改後的代碼:rem
SSICAViewController *ssicaVC = [[SSICAViewController alloc] init]; NSArray *vcs = self.navigationController.viewControllers; NSMutableArray *currentControllers = [NSMutableArray arrayWithArray:vcs]; [currentControllers removeLastObject]; [currentControllers addObject:ssicaVC]; [self.navigationController setViewControllers:currentControllers animated:YES];
最近在學習swift,也開始在項目中使用swift。以後會更新一波swift學習過程當中遇到的坑。it