Repository navigation
2.2 UITabController
tamotamago edited this page Apr 12, 2013
·
9 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;
@endMixiFirstViewController.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 を管理させてください。
- 導入
- Objective C の基礎
- メモリ管理
- UIViewController1 - UIViewController のカスタマイズ
- UIViewController2 - ModalViewController
- UIViewController3 - ライフサイクル
- UIKit 1 - container -
- UINavigationController
- UITabController
- Custom Container View Controller
- UIKit 2 - table view -
- UITableView について
- UITableViewDelegate, UITableViewDatasource について
- custom UITableViewCell の作成
- (iOS6) UIRefreshControl について
- UIKit 3 - images -
- UIImage (CoreGraphics)
- UIImageView
- Accets Library
- CoreImage
- UIKit 4 - text -
- UILabel
- UITextView
- KeybordNotification
- 非同期処理系
- NSURLConnection (json シリアライザ)
- Blocks
- GCD
- View アニメーション、回転対応
- View animation
- Core animation
- lotate
- ローカルキャッシュ
- UserDefaults
- FileManager
- CoreData
- SQLite
- Instruments
- leak
- time profiler
- その他
- 単体テスト (GHUnit)
- 結合テスト (KIF)
- cocoaPods でライブラリ管理




