2011-01-02 7 views

답변

0

당신은 UINavigationController가를 사용해야하고이 기능은 "무료"거의 온다. 생성 단계에서 먼저보기 컨트롤러를 만듭니다. 그런 다음 UINavigationController를 만들어 이전에 만든보기 컨트롤러를 전달합니다. 나중에 탐색 막대를 밀어 내고 싶을 때 pushViewController : animated : 함수 호출을 사용하여 새보기 컨트롤러를 푸시합니다. 아래의 코드를 살펴 :

// Creation time 
// Create your own view controller. below is just an example 
UIViewController *myController = [[UIViewController alloc] init]; 

// Now create a navigation controller 
UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:myController]; 

// Retain the above somehow, add their view to the Window etc. - not detailed here 

// Later, when you want to slide away your controller, you need to push a new view controller. 
// The below code assumes "self" is actually myController which you defined previously: 

UIViewController *newController = [[UIViewController alloc] init]; 
[self.navigationController pushViewController:newController animated:YES]; 
// The above line will make the controller and navigation bar slide away, revealing your new controller 

이 내가이 당신이 찾고 있던 무슨 희망 메모리 관리 등 모든 세부 사항을 포함하지 않는 매우 거친 코드 샘플입니다.

+0

어떤 방법으로 컨트롤러를 밀어 낼 수 있습니까? – MarcoA

+0

pushViewController : animated : 메서드는 새 컨트롤러를 제자리로 밀어 넣는 메서드입니다 (이전 컨트롤러를 화면 밖으로 밀어냅니다). 작업이 끝나고 초기 컨트롤러로 다시 슬라이드하려면 popViewControllerAnimated를 사용해야합니다. – Ariel

관련 문제