This repository has been archived by the owner on Jun 20, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 336
2.2 UITabController
tamotamago edited this page Apr 12, 2013
·
19 revisions
UITabBarController Class Reference | iOS View Controllerプログラミングガイド
UITabBarController は TabBar インタフェースを用いて ViewController を管理するコンテナです。
UITabBarController における重要な property と method は以下の通りです。
- viewControllers - viewController が含まれている NSArray
- selectedViewController - 現在表示されている ViewController を取得、別のViewControllerに変更可能なプロパティ
- delegate - 表示変更などのイベントを取得できる delegate UITabBarControllerDelegate Protocol
tab の表示は ViewController の UITabBarItem を設定することで変更可能
viewControllers に 5 つ以上の ViewController を管理させる場合、Tab では 4 つを管理し、それ以外の ViewController は more として管理されます。
MixiFirstViewController.h
#import <UIKit/UIKit.h>
@interface MixiFirstViewController : UIViewController
-(id)initWithImageName:(NSString *)imageNmae;
@end
MixiFirstViewController.m
-(id)initWithImageName:(NSString *)imageNmae;
{
self = [super initWithNibName:@"MixiFirstViewController" bundle:nil];
if (self) {
self.title = imageNmae;
self.tabBarItem.image = [UIImage imageNamed:imageNmae];
}
return self;
}
MixiAppDelegate.m
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
UIViewController *vc1 = [[MixiFirstViewController alloc] initWithImageName:@"first"];
UIViewController *vc2 = [[MixiSecondViewController alloc] initWithNibName:@"MixiSecondViewController" bundle:nil];
UIViewController *vc3 = [[MixiFirstViewController alloc] initWithImageName:@"third"];
UIViewController *vc4 = [[MixiFirstViewController alloc] initWithImageName:@"fourth"];
UIViewController *vc5 = [[MixiFirstViewController alloc] initWithImageName:@"fifth"];
UIViewController *vc6 = [[MixiFirstViewController alloc] initWithImageName:@"sixth"];
self.tabBarController = [[UITabBarController alloc] init];
self.tabBarController.viewControllers = @[vc1, vc2, vc3, vc4, vc5, vc6];
self.window.rootViewController = self.tabBarController;
[self.window makeKeyAndVisible];
return YES;
}
画像ファイルはこちら
「イメージ」
tabBar の上にバッジを表示することが可能です。
self.tabBarItem.badgeValue = @"5";
tabBarControlelr の中の一つに NavigationController を管理させてください。
はじめに
-
導入
-
1.3 UIViewController1 UIViewController のカスタマイズ(xib, autoresizing)
-
UIKit 1 - container, rotate-
-
UIKit 2- UIView -
-
UIKit 3 - table view -
-
UIKit 4 - image and text -
-
ネットワーク処理
-
ローカルキャッシュと通知
-
Blocks, GCD
-
設計とデザインパターン
-
開発ツール
-
テスト
-
In-App Purchase
-
付録