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
감사합니다. Greg. 이 시나리오에서 ViewControllers를 탭에 할당하는 방법을 잘 모르겠습니다. – awDemo