내 코드는 작동하지만 이해하려고합니다. "표시"세그먼트 (사용자가 편집을 위해 테이블보기 셀을 클릭 할 때 표시됨) 또는 "현재의 모드 적"세그먼트 (사용자가 "편집"버튼을 클릭 할 때 표시 될 수있는 "취소"버튼을 관리하는 데 사용되는 코드입니다. + "바 버튼 항목을 사용하여 테이블보기에 새 셀을 추가합니다). 아래 다이어그램. 나는 UINavigationController와 navigationController 속성에 혼란스러워진다. 아주 분명한 것을 놓친다면 사과드립니다. 여기 신속한 이해 어려움 이해 UINavigationController 및 navigationController re : presentingViewController
// Apple says below is nil if neither the current view controller nor any of its ancestors were presented modally
let isPresentingInAddMode = presentingViewController is UINavigationController
if isPresentingInAddMode {
// Modal segues need to be dismissed
dismiss(animated: true, completion: nil)
} else {
// But Show segues are "popped" off of a stack of controllers.
navigationController!.popViewController(animated: true)
}
내가 이해하고 있지 않다 내용은 다음과 같습니다 - 나는 실행 중에 일시 정지하는 "쇼"SEGUE를 통해 상세보기 컨트롤러에 도착하고있는 navigationController에서 옵션을 클릭 한 경우, 엑스 코드는이 UINavigationController가이 있다고 말한다 ? 그리고 else 조건 내에서 실행을 일시 중지하면 & 디버거를 사용하여 po navigationController! == nil - Xcode에서 false라고 평가하므로 navigationController는 유효한 UINavigationController입니다. I는 "쇼"를 이용하여 제출 한 경우
는 왜
presentingViewController is UINavigationController
맨 위의 문에서 true로 동일시하지 않습니다?
아마도 "현재"를 이해하지 못하고 있습니다. 모달 쎄그 (modal segues)에서만 발생하는 무언가를 보여주고 있는데, 그래서 presentingViewController가 없습니까? 그리고 내 스토리 보드 (아래 그림 참조)를 다시 보면 조감도 컨트롤러의 조상 중 하나는 내비게이션 컨트롤러가있는 presentingViewController의 Apple 정의에 따라 테이블 컨트롤러가 있습니다. presentingViewController는 UINavigationController입니다. 이 경우에도 마찬가지입니까?
그리고 것 :
presentingViewController != nil
는 동일한 결과를 얻을 또는 presentingViewController이 UINavigationController가되어 있는지 확인하는 중요한 이유가?
나를 분석 할 수있을만큼 친절한 누군가에게 고마워. 존
은 "ShowDetail"SEGUE 테이블 뷰 셀에서 발생는 "쇼"SEGUE입니다. "AddItem"segue는 일종의 "현재 모드"이고 추가 바 버튼 항목에서 시작됩니다.
그것은 테이블 뷰 컨트롤러 SEGUE 코드에 대한 준비를 볼 가능성 필요는 없습니다,하지만 당신은 호기심이 있다면 : 아마도 내가 "현재"를 이해하고 있지 않다
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
// Get the new view controller using segue.destinationViewController.
// Pass the selected object to the new view controller.
if segue.identifier == "ShowDetail" { // is this the "ShowDetail" segue? and if it is...
// ... get the IndexPath for the row the user clicked on (the selected row)
let indexPath = tableView.indexPathForSelectedRow!
let destinationViewController = segue.destination as! DetailViewController // downcast the destination as the specific class DetailViewController
// Get the to do item that the user clicked on
let selectedToDo = toDoArray[indexPath.row]
// Pass selectedToDo to the toDoItem variable in our destinationViewController
destinationViewController.toDoItem = selectedToDo
}
}
ViewControllers를 – muescha
이라고 부르는 곳에 코드를 추가하십시오.'(backtick) – muescha
안녕하세요 - 쇼 세그가 있습니다. - "ShowDetail"이 식별자입니다. "AddItem"은 표 막대 셀에서 "ShowDetail"이 호출되는 동안 추가 막대 단추 항목에서 호출됩니다. 위의 테이블 뷰 컨트롤러에 대한 "prepare (for segue :) 코드를 추가하겠습니다. 그러나 다시는 중요하지 않습니다. UINavigationController 대 navigationController를 이해해야합니까? Thx – Gallaugher