私は Objective-C を勉強しており、学習中にアプリを作成し始めました。「ViewController」と「secondViewController」という 2 つの「View Controller」を持つ「Single View Application」を作成しました。その後、「UITabBarController」を追加することを考えたので、チュートリアルに従って、AppDelegate.m で次のコードを使用しました。
(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
[self customizeInterface];
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
UITabBarController *tabController = [[UITabBarController alloc] init];
UIViewController *viewController1 = [[UIViewController alloc] init];
UITabBarItem *tab1 = [[UITabBarItem alloc] initWithTitle:@"Artists" image:[UIImage imageNamed:@"artist-tab.png"] tag:1];
[viewController1 setTabBarItem:tab1];
UIViewController *viewController2 = [[UIViewController alloc] init];
UITabBarItem *tab2 = [[UITabBarItem alloc] initWithTitle:@"Music" image:[UIImage imageNamed:@"music-tab.png"] tag:2];
[viewController2 setTabBarItem:tab2];
tabController.viewControllers = [NSArray arrayWithObjects:viewController1,
viewController2, nil];
self.window.rootViewController = tabController;
[self.window makeKeyAndVisible];
// Override point for customization after application launch.
return YES;
}
ここにViewController.mがあります
#import "ViewController.h"
@interface ViewController ()
@end
@implementation ViewController
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end
アプリケーションを実行すると、タブ バーは機能しますが、作成した ViewController ではなく空白の画面が表示されます。私は初心者なので、各タブでそれぞれView Controllerをリンクまたは表示する方法を教えてください。
当たり前のことも全部言ってくださいますので、よろしくお願いします。前もって感謝します