본문 바로가기
iOS/iOS

특정 viewcontroller로 pop

by 패쓰킴 2022. 10. 13.
728x90

방법1.

NSArray * vcStack = self.navigationController.viewControllers;
NSInteger index = vcStack.count - 1;
        
while (YES) {
  index--;
  UIViewController *vc = [vcStack objectAtIndex:index];
  if([vc isKindOfClass:[원하는VC class]]){
    [self.navigationController popToViewController:vc animated:YES];
    return;
  }
}


방법2.

let controllers = self.navigationController?.viewControllers
for vc in controllers! {
  if vc is AddFavoriteVC {
    self.navigationController?.popToViewController(vc as! AddFavoriteVC, animated: true)
  }
}
728x90

'iOS > iOS' 카테고리의 다른 글

UITabBar  (0) 2022.10.19
UIscrollView dynamic height  (0) 2022.10.14
Animation  (0) 2022.10.11
지도앱 URL Scheme  (0) 2022.10.05
UICollectionView 페이징  (1) 2022.09.30

댓글