forked from mixi-inc/iOSTraining
-
Notifications
You must be signed in to change notification settings - Fork 0
2.2 UITabController
tamotamago edited this page Apr 18, 2013
·
11 revisions
UITabBarController Class Reference | iOS View Controllerプログラミングガイド
UITabBarController は TabBar インタフェースを用いて ViewController を管理するコンテナです。
Source:View Controller Programming Guide for iOS
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 *)imageName;
{
self = [super initWithNibName:@"MixiFirstViewController" bundle:nil];
if (self) {
self.title = imageName;
self.tabBarItem.image = [UIImage imageNamed:imageName];
}
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, rotate-
- UINavigationController
- UITabController
- Custom Container View Controller
- Supporting Multiple Interface Orientations
- UIKit 2- UIView -
- UIView
- UIView のカスタマイズ
- UIView Animation
- UIKit 3 - table view -
- UITableView について
- UITableViewとNavigationController
- custom UITableViewCell の作成
- 4.4 UITableViewのその他のオプション、カスタマイズ
- UIKit 4 - images -
- UIImage (CoreGraphics)
- UIImageView
- Accets Library
- CoreImage
- UIKit 4 - text -
- UILabel
- UITextView
- KeybordNotification
- 非同期処理系
- NSURLConnection (json シリアライザ)
- Blocks
- GCD
- ローカルキャッシュ
- UserDefaults
- FileManager
- CoreData
- SQLite
- Instruments
- leak
- time profiler
- その他
- 単体テスト (GHUnit)
- 結合テスト (KIF)
- cocoaPods でライブラリ管理