0

내 의도는 클릭하여 UIButton으로 기본보기가있는 앱을 만드는 것입니다. 단추 중 하나를 클릭하면 TabBarController보기로 들어갑니다.내비게이션 컨트롤러에서 튀어 나오면 같은 탭에 머무는 방법

예를 들어, sample1을 누르면 버튼이 자동으로 TabBarController보기에서 두 번째 탭을 선택합니다. 그리고 sample2 버튼을 클릭하면 3 번째 탭으로 이동하고, 더 많은 버튼은 테이블 뷰를 표시하는 탭으로 이동합니다.

내 문제는 MoreViewController의 UITableViewCell을 클릭하여 자세히보기로 들어갈 때 발생합니다. 하지만, 왼쪽 위 버튼을 클릭하여 TabBarController로 돌아가고 싶을 때. 탭이 기본보기에서 클릭 한 탭으로 바뀝니다.

내가, 여전히 MoreViewControllerviewWillAppear viewWillDisappear 같이 대리자 메서드에 selectedIndex의 값을

- (void)tableView:(UITableView *)tableView 
didSelectRowAtIndexPath:(NSIndexPath *)indexPath 

또는 다른 장소를 값을 설정하더라도 변경되지 않은 TabBarController의 selectedIndex의를 보인다

동일하게 유지됩니다.

샘플 코드

는 여기 -> http://uploadingit.com/file/qxfbw4cuzjdkk56v/9s.zip

은 아무도이 문제를 해결하는 방법을 알고 있습니까?

답변

0

사실 메인 탐색 컨트롤러를 사용하여 메인보기에서 Tabbar 컨트롤러를 밀고 있습니다. 따라서 POP를 내보낼 때 기본보기로 이동합니다.

tabBar_Controller = [[UITabBarController alloc] init]; 
NSMutableArray *localControllersArray =[[NSMutableArray alloc]initWithCapacity:2]; 


firstViewController = [[FirstViewController alloc] initWithNibName:@"firstViewController" bundle:nil]; 
nav = [[UINavigationController alloc] initWithRootViewController:firstViewController]; 
nav.tabBarItem.title = @"item1"; 
nav.navigationBar.barStyle = UIBarStyleBlack; 
[localControllersArray addObject:nav]; 
[self setNav:nil]; 

secondViewController = [[SecondViewController alloc] initWithNibName:@"secondViewController" bundle:nil]; 
nav = [[UINavigationController alloc]initWithRootViewController:secondViewController]; 
nav.tabBarItem.title = @"item2"; 
[localControllersArray addObject:nav]; 
[self setNav:nil]; 

tabBar_Controller.viewControllers = localControllersArray; 
tabBar_Controller.delegate = self; 
tabBar_Controller.selectedIndex = 0; 
[self.window addSubview:tabBar_Controller.view]; 
TabBar의

작성이 시도