Apple Developer에서 튜토리얼을 공부하고 있습니다 : Start Developing iOS Apps (Swift), 나는 push와 modal segue와 혼동합니다.Navigation Stack에서 ViewController 팝업 팝업
두 가지 시나리오, 취소 버튼을 누르면 그 장면이 기각하는 다른 방법을 호출, 현장에서 장면 1에 백업, 2
을 저장하고 탐색 모음에 취소 버튼이 있습니다
@IBAction func cancel(_ sender: UIBarButtonItem) {
// Depending on style of presentation (modal or push presentation), this view controller needs to be dismissed in two different ways.
let isPresentingInAddMealMode = presentingViewController is UINavigationController
if isPresentingInAddMealMode {
dismiss(animated: true, completion: nil)
}
else if let owningNavigationController = navigationController{
owningNavigationController.popViewController(animated: true)
}
else {
fatalError("The MealViewController is not inside a navigation controller.")
}
}
가
scene이 모달 segue로 표시되면 dismiss (animated : completion :)가 호출되고 장면이 push segue로 표시되면 popViewController (animated :)가 호출되어 ViewController가 표시됩니다. 네비게이션 스택
그러나 저장 단추의 경우 자습서는 장면 2의 메서드를 재정의하고 (송신자 :), 작업 1의 동작 메서드 unwindToMealList (보낸 사람 :)를 재정의합니다. 그리고 Save 단추를 Exit (장면 도크의 단추)로 끌고 unWindToMealList (sender :) 메서드를 선택하십시오. 그래서 흐름은 다음과 같습니다 : 준비 (송신자 :) -> 장면 2가 사라지고 장면 1이 나타남 -> unWindToMealList (발신자 :)
나는 장면 2와 장면 2를 명백히 해고하지 않았다. 저장 버튼을 누르면 탐색 스택의 ViewController가 제거됩니다. 모달 segue가 ViewController를 탐색 스택으로 푸시하지 않을 것이라고 알고 있지만 push segue가 밀어 넣을 것입니다. 코드 스 니펫이 탐색 스택에서 팝업되지 않는 이유는 무엇입니까?
감사합니다.
알 수 있습니다. 감사! – Nestarneal