2010-02-17 2 views
4
view1 = [[View1 alloc] init]; //Create the first view 
UINavigationController *navigationController1 = [[UINavigationController alloc] initWithRootViewController:view1]; 
navigationController1.navigationBar.tintColor =[UIColor blackColor]; 

View1은 UIViewController에서 상속됩니다. 그래서 * 1 뷰를 만든 다음 UINavigationController를 만들고 * navigationController1을 호출합니다. 두 항목을 어떻게 연결합니까? 대단히 감사합니다.코드의 뷰에 UINavigationController를 어떻게 추가합니까?

답변

0

약간 혼란 스러울 수도 있습니다. A UINavigationController은 일반적으로 UIViewController에 첨부되며 그 자체는 UIView을 포함합니다.

코드를 직접 작성하기 전에 Xcode의 새 프로젝트 템플릿 목록에서 사용할 수있는 탐색 컨트롤러 샘플 응용 프로그램 프로젝트를 살펴보고 어떻게 작동하는지 알아볼 수 있습니다.

10

보기 컨트롤러와 탐색 컨트롤러를 연결하는 방법은보기 컨트롤러를 탐색 스택으로 밀어 넣는 것입니다. 예를 들면 다음과 같습니다.

UIViewController * yourViewController = [[UIViewController alloc] init]; 
UINavigationController * navigation = [[UINavigationController alloc] init]; 
[navigation pushViewController:yourViewController animated:NO]; 
[yourViewController release] 

마지막으로 네비게이션 컨트롤러가 유지하므로 마지막으로 뷰 컨트롤러를 해제합니다.

+2

당신은 루트 볼 수있는 init을 할 수 UINavigationController가 * 탐색 = [[UINavigationController가의 ALLOC] initWithRootViewController : yourViewController] –

관련 문제