카테고리 없음

<ios프로젝트2> 네비게이션 뷰컨트롤러

studying develop 2020. 3. 19. 17:00

네비게이션 뷰컨을 사용해보자.

 

[https://developer.apple.com/documentation/uikit/uinavigationcontroller]

[https://calmone.tistory.com/entry/iOS-UIKint-in-Swift-4-UINavigationController-%EC%82%AC%EC%9A%A9%ED%95%98%EA%B8%B0-Display-UINavigationController]

 

좀 햇갈린 부분이, 네뷰컨을 어느 뷰컨에 임베드하냐인데, 약간 이런 개념 같다. 네뷰컨을 지정해주면 다른 뷰컨을 그 안으로 푸쉬할 수 있는거 같다.

 

그리고 이건 prepare

[https://stackoverflow.com/questions/28788416/swift-prepareforsegue-with-navigation-controller]

 

뷰컨을 가져와야 된다.


push vs present

 

[https://developer.apple.com/documentation/uikit/uinavigationcontroller] 이 부분에서 container라는 단어에 주목해서 다시 보겠다.

 

Class

UINavigationController

A container view controller that defines a stack-based scheme for navigating hierarchical content.

설명 자체가 컨테이너 뷰컨트롤러라 한다. 컨테이너 뷰컨인데 스택에 기반한 계층적인 콘텐츠들을 네비게이팅하는 구조라함.

 

음 이제 오버뷰도 보자.

Overview

A navigation controller is a container view controller that manages one or more child view controllers in a navigation interface. In this type of interface, only one child view controller is visible at a time. Selecting an item in the view controller pushes a new view controller onscreen using an animation, thereby hiding the previous view controller. Tapping the back button in the navigation bar at the top of the interface removes the top view controller, thereby revealing the view controller underneath.

 

네뷰컨은 한개 또는 그이상의 자식 뷰컨들을 네비게이션 인터페이스에서 관리하는 컨테이너 뷰컨이다. 이러한 인터페이스 타입에서는 단 한개의 자식 뷰컨만 한 시점에 볼 수 있다. 뷰컨에서 아이템을 선택하는 것은 새로운 뷰컨을 애니메이션으로 스크린에 보여준다, 그러므로 이전의 뷰컨을 숨긴다. 뭐 이 문장은 아는 내용이다. 

 

즉 여기서 잘 몰랐던게, 여러개의 자식 뷰컨들을 관리할 수 있는 컨테이너라는 점이다.!! present는 그냥 한개만 보여주는건데, 음 그게 자식구조인지 아닌지는 모르겠따.

 

Use a navigation interface to mimic the organization of hierarchical data managed by your app. At each level of the hierarchy, you provide an appropriate screen (managed by a custom view controller) to display the content at that level. Figure 1 shows an example of the navigation interface presented by the Settings application in iOS Simulator. The first screen presents the user with the list of applications that contain preferences. Selecting an application reveals individual settings and groups of settings for that application. Selecting a group yields more settings and so on. For all but the root view, the navigation controller provides a back button to allow the user to move back up the hierarchy.

 

앱에서 네비게이션 인터페이스로 계층적 데이터를 관리하는걸 흉내낼 수 있다함.!! 각 계층의 레벨에서, 내가 적절한 스크린(뷰컨)을 보여주라함. 

 

A navigation controller object manages its child view controllers using an ordered array, known as the navigation stack. The first view controller in the array is the root view controller and represents the bottom of the stack. The last view controller in the array is the topmost item on the stack, and represents the view controller currently being displayed. You add and remove view controllers from the stack using segues or using the methods of this class. The user can also remove the topmost view controller using the back button in the navigation bar or using a left-edge swipe gesture.

 

네이게이션 컨트롤러 오브젝트는 자식 뷰컨들을 정렬된 배열을 이용해 관리한다, 네비게이션 스택이라함. !! 음 배열로 관리한다 , 스택구조라는거 같음.! 배열에서 첫 뷰컨은 루트 뷰컨이고 스택의 가장 아래를 의미한다. 마지막 뷰컨은 가장 위의 뷰컨이다, 그리고 현재 보여지는 뷰컨을 디스플레이 한다. 나는 이제 세그나 다른 메소드들을 사용해 스택에서 뷰컨을 제거하거나 추가할 수 있다. 사용자는 또한 가장 가장 위의 뷰컨을 백 버튼으로 삭제 할수있다.

 

 

좀 건너뛰고

 

 

Adapting to Different Environments

The navigation interface remains the same in both horizontally compact and horizontally regular environments. When toggling between the two environments, only the size of the navigation controller’s view changes. The navigation controller does not change its view hierarchy or the layout of its views.

 

위의 내용은 이해가 안된다;;

 

When configuring segues between view controllers on a navigation stack, the standard Show and Show Detail segues behave as follows:

 

네비게이션 스택위의 뷰컨들 사이에서 세그를 설정할때, 쇼와 쇼 디테일 두개가 있다.

  • Show segue—The navigation controller pushes the specified view controller onto its navigation stack.

  • Show Detail segue—The navigation controller presents the specified view controller modally.

The behaviors of other segue types are unchanged.

 

쇼 세그는, 네뷰컨이 특정 뷰컨을 네비게이션 스택위로 푸쉬한다.

쇼 디테일 세그는 - 네뷰컨이 특정 뷰컨을 modally하게 present 한다