今、私は8種類のビューを持つビューベースのアプリケーションを作成しました。 3つのビューにタブバーを表示したい。このタブバーには3つのアイテムがあり、ユーザーは3つのビューに切り替えることができます。ビューベースのアプリケーションに3つのアイテムを含むタブバーを追加する
どうすればいいですか?どうもありがとう。
AppDelegate.h
@interface LoginPageAppDelegate : NSObject <UIApplicationDelegate, UITabBarControllerDelegate> {
UIWindow *window;
LoginPageViewController *viewController;
UITabBarController *tabBarController;
}
@property (nonatomic, retain) IBOutlet UIWindow *window;
@property (nonatomic, retain) IBOutlet LoginPageViewController *viewController;
@property (nonatomic, retain) IBOutlet IBOutlet UITabBarController *tabBarController;
@end
AppDelegate.m
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
tabBarController = [[UITabBarController alloc] init];
tabBarController.delegate=self;
RequestPage* requestPage = [[RequestPage alloc] init];
UIViewController *RequestPageView = [[UIViewController alloc] initWithRootViewController:requestPage];
StatusPage* statusPage = [[StatusPage alloc] init];
UIViewController *StatusPageView = [[UIViewController alloc] initWithRootViewController:statusPage];
NSArray* controllers = [NSArray arrayWithObjects:RequestPageView, StatusPageView, nil];
tabBarController.viewControllers = controllers;
[window addSubview:tabBarController.view];
[self.window makeKeyAndVisible];
return YES;
}
RequestPage.m
- (id)init {
self.title = @"Request Page";
UIImage* anImage = [UIImage imageNamed:@"3.png"];
UITabBarItem* theItem = [[UITabBarItem alloc] initWithTitle:@"Request Page" image:anImage tag:2];
self.tabBarItem = theItem;
[theItem release];
return self;
}
タブ名とイメージを設定するにはどうすればよいですか? –
私は自分の答えを編集しました。それを確認してください。 – Nitish
迅速な返信をありがとうございます。私は何が間違っているのか分かりません。これで本当に新しいです。私が行ったことで私の質問を編集しました。どうぞご覧ください。アプリの起動中にクラッシュします。 –