iOS
[iOS] navigationController.present()를 하면 어떻게 될까?
lizzydev
2023. 1. 6. 15:02
print(navigationController.viewControllers) // [HomeVC,FriendsListVC]
guard let vc = UIStoryboard(name: "FriendsAdd", bundle: nil).instantiateViewController(withIdentifier: FriendsAddVC.identifier) as? FriendsAddVC else { return }
vc.modalPresentationStyle = .fullScreen
navigationController.present(vc, animated: true)
print(navigationController.viewControllers)// [HomeVC,FriendsListVC]
navigationController를 가지고 present()를 하면 현재 네비게이션 스택의 topViewcontroller인 현재 보여지는 뷰컨트롤러 위에 present 됩니다.
하지만 navigationController.viewControllers에는 추가 되지 않습니다.
즉, push가 아닌 present를 한 것이기에 네비게이션 스택에는 쌓이지 않습니다.