0

프로그래밍 방식으로 내 TabBarController 응용 프로그램에 NavigationController를 추가하려고합니다.프로그래밍 방식으로 TabBarController에 NagivationController 추가하기

내 코드 : 나는 ThirdViewController에있는 tableview/detailview를 추가하고, 나는 그것을 그렇게 할 수있는 네비게이션 컨트롤러를 만들 필요가 있음을 이해하려고 노력하고

UIViewController *viewController1 = [[FirstViewController alloc] 
initWithNibName:@"FirstViewController" bundle:nil]; 

UIViewController *viewController2 = [[SecondViewController alloc] 
initWithNibName:@"SecondViewController" bundle:nil]; 

UIViewController *viewController3 = [[ThirdViewController alloc] 
initWithNibName:@"ThirdViewController" bundle:nil]; 

UITabBarController *tabController = [[UITabBarController alloc] init]; 
tabController.viewControllers = @[viewController1, viewController2, viewController3]; 
return tabController; 

.

또 다른 포럼은 내가 아래와 같은 것을 할 수 있다고 말하지만, 나는 그들의 프로젝트가 말한 것을하기 위해 모든 일을 바꾸는 데 어려움을 겪고있다. 누구든지 코드의 상단 섹션을 조작하고 NavigationController를 TabBarController에 프로그래밍하는 방법을 알고 있습니까?

내가 시도

UIViewController *viewController1, *viewController2; 

viewController1 = [[[UIViewController alloc] initWithNibName:@"FirstViewController_iPhone" 
bundle:nil] autorelease]; 
UINavigationController *navigationcontroller = [[[UINavigationController alloc] 
initWithRootViewController:viewController1] autorelease]; 

viewController2 = [[[UIViewController alloc] 
initWithNibName:@"SecondViewController_iPhone" bundle:nil] autorelease]; 

self.tabBarController = [[[UITabBarController alloc] init] autorelease]; 
self.tabBarController.viewControllers = [NSArray arrayWithObjects:navigationcontroller, 
viewController2, nil]; 
이 모두 함께 넣고는 다음과 같습니다 후임의 샘플 코드 :

UIViewController *viewController1 = [[FirstViewController alloc] 
initWithNibName:@"PDCFirstViewController" bundle:nil]; 

UIViewController *viewController2 = [[SecondViewController alloc] 
initWithNibName:@"SecondViewController" bundle:nil]; 

viewController3 = [[UIViewController alloc] initWithNibName:@"ThirdViewController" 
bundle:nil]; 
UINavigationController *navigationcontroller = [[UINavigationController alloc] 
initWithRootViewController:viewController3]; 

self.tabBarController = [[UITabBarController alloc] init]; 
self.tabBarController.viewControllers = [NSArray 
arrayWithObjects:viewController1,viewController2,navigationcontroller, nil]; 

return 0; 

내가 응용 프로그램을 모든 오류를 바로 얻을하지 않습니다 피장 ​​장이 된. 어떤 도움이라도 좋을 것입니다! 다들 감사 해요!

+2

"모든 종류의 문제"는 당신의 문제에 대한 매우 유용한 설명이 아닙니다. 다른 사람의 코드 대신 자신의 게시물을 게시하고 오류 메시지의 내용을 확인하십시오. 그렇지 않으면 다른 사람이 해결하고자하는 일종의 과제라고 생각할 수 있습니다. –

+0

어떤 종류의 문제가 있습니까? 컴파일러가 경고합니까? – Shmidt

+0

@ DanielSchneller 안내에 감사드립니다. 내가 실패한 코드를 포함하도록 항목을 업데이트했습니다. :) -이 모든 작업을 약 2 일 동안 진행하려했습니다. 모든 앞으로의 진전은 크게 감사하겠습니다! – Brandon

답변

0

나는 비슷한 질문에 대한 답을 주었다. 당신은 이걸로 당신의 해결책을 찾을 수 있습니다 answer

관련 문제