0

JMTabViewGitHub で Jason Morrissey によって呼び出されたカスタム タブ ビューの使用方法を理解しようとしています。(直接聞いてみましたが、返事がありませんでした。)

UITabBarControllerプログラムでビューコントローラーを作成して割り当てる方法を知っています。私が理解できないのはUITableViewController、この例の 4 つのタブのそれぞれについて、4 つの と他の 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
4

1 に答える 1

0

私はその特定のライブラリに精通していませんが、それが UITabViewController と同様のパターンに従っている場合、App Delegate の .h ファイルでタブのプロパティを作成し (後で参照する必要がある場合)、.h ファイルでインスタンスを作成します。メートル。タブを配置するだけで、タブを直接参照する必要がなくなった場合は、それらを .m (おそらく applicationDidFinishLaunching) で定義し、タブとして割り当てて、タブ コントローラーがそこから取得できるようにする必要があります。

于 2011-09-26T17:05:37.000 に答える