我试图弄清楚如何使用我JMTabView
在 GitHub 上找到的由 Jason Morrissey 调用的自定义选项卡视图。(我试着直接问他,但没有得到回应。)
我知道如何以编程方式创建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