0

UIViewController에 childViewController로 추가 된 UIViewController가 있습니다.자체가 childviewcontroller로 UIViewController에 추가 된 탐색 컨트롤러에 테이블 뷰를 추가하는 방법

exampleView = [[UIViewController alloc] init]; 

//Setting the frame of the child UIViewController 

CGRect frame = self.view.frame; 
frame.origin.y = frame.origin.y + 83.0; 
frame.size.height = 200.0; 
exampleView.view.frame = frame; 

[self addChildViewController:exampleView]; 
[self.view addSubview:exampleView.view]; 
[exampleView didMoveToParentViewController:self]; 

나는 다음 childViewController에

//Adding navigation controller to the child view. 

UINavigationController *nav = [[UINavigationController alloc]  initWithRootViewController:exampleView]; 
nav.navigationBar.translucent = NO; 
[exampleView.view addSubview:nav.view]; 
exampleView.title = @"mynameasdasd"; 

참고은 UINavigationController를 추가 : 내보기의 중앙에 탐색 컨트롤러를 필요로하기 때문에 나는이 작업을 수행 (전체 화면 크기를 점유하지 않음).

이제이 navigationController에 TableView를 추가하고 일반적인 탐색을 계속하고 싶습니다. 어떻게해야합니까? 이 탐색 컨트롤러에 테이블 뷰를 추가 할 수 없습니다.

+0

네비게이션 컨트롤러에 테이블 뷰를 추가 할 수 없습니다. 테이블 뷰가 포함 된 뷰 컨트롤러는 탐색 컨트롤러에만 추가 할 수 있습니다. – Mundi

+0

죄송합니다. 내 실수. 나는 tableviewController를 추가하고 있었다. navtablecontroller = [[UITableViewController alloc] init]; [nav pushViewController : navtablecontroller animated : YES]; 그러나 나는 tableview를 볼 수 없습니다. – Viggy

+0

그래, 내가 받아 들일 수있는 대답을 쓸거야. – Mundi

답변

0

initWithRootViewController에 전달할 매개 변수가 잘못되었습니다. UITableViewController

UITableViewController *tvc = [[UITableViewController alloc] init]; 
tvc.delegate = <Put your UITableViewDelegate here> 
tvc.datasource = <Put your UITableViewDatasource here> 
UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:tvc]; 
nav.navigationBar.translucent = NO; 
[exampleView.view addSubview:nav.view]; 
exampleView.title = @"mynameasdasd"; 
+0

내가 말했듯이 나는 테이블을 볼 수 없다. 머리 위로부터 만들 수있는 일반적인 실수를 말할 수 있습니까? 나는 navbar를 볼 수있다. 테이블이 없습니다. – Viggy

0

네비게이션 컨트롤러에 테이블 뷰를 추가 할 수 없습니다. 테이블 뷰가 포함 된 뷰 컨트롤러는 탐색 컨트롤러에만 추가 할 수 있습니다.