Interfacebuilder에서 설정 한 UITabbarController가 있습니다. tabbarcontroller에는 5 개의 탭이 있으며 첫 번째 페이지는 시작 페이지이고 두 번째 페이지는 UITableViewController입니다. 둘 다 NavigationController가 있습니다. 두 번째 탭에는 카테고리 목록이 표시됩니다. 앱을 실행하면 모두 정상입니다. 두 번째 탭을 누르면 네비게이션 컨트롤러로보기가 완벽하게로드됩니다. 하지만 내가하고 싶은 일은 첫 번째 탭의 링크를 사용하여 두 번째 탭에 특정 카테고리를로드 할 수있게하려는 것입니다.UITabbarController 설정보기
그래서 제가 한 일은 내 AppDelegate에에 다음과 같은 기능을 추가했고 전화 내 첫 번째 탭의보기에서이다 :
- (void)loadCategoryViewUsingCategoryId:(NSString*)categoryId
{
CategoryViewController *categoryView = [[CategoryViewController alloc] initWithLoadingCategoryUsingCategoryId:categoryId];
if (!categoryView) {
UIAlertView *errorView;
errorView = [[UIAlertView alloc]
initWithTitle: NSLocalizedString(@"Whoops", @"oddsAppAppDelegate")
message: NSLocalizedString(@"I did not found the requested category. Sorry!", @"oddsAppAppDelegate")
delegate: self
cancelButtonTitle: NSLocalizedString(@"Close", @"oddsAppAppDelegate") otherButtonTitles: nil];
[errorView show];
[errorView autorelease];
}
else {
self.tabBarController.selectedIndex = 1;
self.tabBarController.selectedViewController = categoryView;
[self.tabBarController.selectedViewController setTitle:@"apa"];
[self.tabBarController.selectedViewController viewDidLoad];
}
}
이 완벽하게 작동,하지만 ... 2 탭을로드 탐색 컨트롤러 도구 모음이 없습니다. 내 탐색 컨트롤러 도구 모음을 유지하려면 어떻게로드 할 수 있습니까?
"CategoryViewController
"은 덧붙여서 UITableViewController
입니다.
안부,
폴 Peelen
안녕하세요, 나는 그것을 시도했지만 실제로는 효과가 없습니다. 그럼 다시, 귀하의 게시물을 생각하고 나에게 다음과 같은 해결책을 준 시작 : \t \t self.tabBarController.selectedIndex = 1; \t \t UINavigationController * nav = [self.tabBarController.viewControllers objectAtIndex : 1]; \t \t nav.viewControllers = [[NSArray alloc] initWithObjects : categoryView, nil]; 이것은 나를 위해 일했습니다. 감사합니다, Paul Peelen –