2011-09-26 3 views
0

GitHub의 Jason Morrissey가 JMTabView이라는 사용자 정의 탭보기를 사용하는 방법을 알아 내려고합니다. (직접 물어 보았지만 응답이 없습니다.)ViewControllers를 사용자 정의 탭보기로 선언 할 위치는 어디입니까?

프로그래밍 방식으로 UITabBarController을 만들고보기 컨트롤러를 지정하는 방법을 알고 있습니다. 내가 알 수없는 것은이 예제에서 네 개의 탭 각각에 대해 네 개의 UITableViewController과 다른 VC를 선언 할 위치입니다. 코드 :

// TabDemoAppDelegate.m -> do I declare them here? 

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 
TabDemoViewController * demoViewController = [[[TabDemoViewController alloc] initWithNibName:nil bundle:nil] autorelease]; 
self.navigationController = [[[UINavigationController alloc] initWithRootViewController:demoViewController] autorelease]; 
//[self.navigationController setNavigationBarHidden:YES]; 

self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; 
[self.window addSubview:self.navigationController.view]; 
[self.window makeKeyAndVisible]; 

return YES; 
} 

// TabDemoViewController.m -> or somewhere in here? 

-(void)addCustomTabView; { // this is a private method 
JMTabView * tabView = [[[JMTabView alloc] initWithFrame:CGRectMake(0, self.view.bounds.size.height - 60., self.view.bounds.size.width, 60.)] autorelease]; 
tabView.autoresizingMask = UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleWidth; 

[tabView setDelegate:self]; 

UIImage * standardIcon = [UIImage imageNamed:@"icon3.png"]; 
UIImage * highlightedIcon = [UIImage imageNamed:@"icon2.png"]; 

CustomTabItem * tabItem1 = [CustomTabItem tabItemWithTitle:@"One" icon:standardIcon alternateIcon:highlightedIcon]; 
CustomTabItem * tabItem2 = [CustomTabItem tabItemWithTitle:@"Two" icon:standardIcon alternateIcon:highlightedIcon]; 
CustomTabItem * tabItem3 = [CustomTabItem tabItemWithTitle:@"Three" icon:standardIcon alternateIcon:highlightedIcon]; 
CustomTabItem * tabItem4 = [CustomTabItem tabItemWithTitle:@"Four" icon:standardIcon alternateIcon:highlightedIcon]; 

[tabView addTabItem:tabItem1]; 
[tabView addTabItem:tabItem2]; 
[tabView addTabItem:tabItem3]; 
[tabView addTabItem:tabItem4]; 

[tabView setSelectionView:[CustomSelectionView createSelectionView]]; 
[tabView setItemSpacing:1.]; 
[tabView setBackgroundLayer:[[[CustomBackgroundLayer alloc] init] autorelease]]; 

[tabView setSelectedIndex:0]; 

[self.view addSubview:tabView]; 
} 

그는 그들이 관련 있다면, 그들은 무엇 ... 블록을 언급하고 내가 VC의 선언 할 곳이다? 그렇다면 어떻게?

// You can run blocks by specifiying an executeBlock: paremeter 
// #if NS_BLOCKS_AVAILABLE 
// [tabView addTabItemWithTitle:@"One" icon:nil executeBlock:^{NSLog(@"abc");}]; 
// #endif 

답변

0

내가 특정 라이브러리에 익숙하지 해요,하지만 UITabViewController 유사한 패턴을 따르는 경우 앱 위임의 .H 파일에 (당신이 나중에 참조 할 필요가있는 경우) 나는 당신의 탭의 속성을 만들 것이며, 그런 다음 .m에 인스턴스를 만듭니다. 탭을 배치하고 더 이상 직접 참조 할 필요가없는 경우 .m (아마도 applicationDidFinishLaunching)에서 정의 할 수 있어야하며 탭으로 할당하고 탭 컨트롤러가 탭을 가져 오도록 허용해야합니다.

+0

감사합니다. Greg. 이 시나리오에서 ViewControllers를 탭에 할당하는 방법을 잘 모르겠습니다. – awDemo

관련 문제