我正在开发一个应用程序,使用Tabbarcontroller(有两个选项卡)。 在iphone上一切正常,但在ipad上,两个tab都会出现在屏幕的中心。
我想把每个选项卡的标题和图像显示在选项卡的中心(考虑到选项卡宽度是屏幕的一半)。
在寻找这些信息时,我遇到了UIEdgeInsetsMake。但是,这里并没有帮助我解决问题。
我不明白在哪里放置这段代码。我试图先将其放置在FirstViewController中,然后放到app delegate中,但对我都没有作用。
以下是我的appDelegete代码:
有人可以帮忙吗?
我想把每个选项卡的标题和图像显示在选项卡的中心(考虑到选项卡宽度是屏幕的一半)。
在寻找这些信息时,我遇到了UIEdgeInsetsMake。但是,这里并没有帮助我解决问题。
我不明白在哪里放置这段代码。我试图先将其放置在FirstViewController中,然后放到app delegate中,但对我都没有作用。
以下是我的appDelegete代码:
FirstViewController *firstVC = [[FirstViewController alloc] init];
UINavigationController *navController1 = [[UINavigationController alloc] initWithRootViewController:firstVC];
//navController1.title = @"First Tab";
navController1.tabBarItem.image = [UIImage imageNamed:@"first.png"];
SecondViewController *secondVC = [[SecondViewController alloc] init];
UINavigationController *navController2 = [[UINavigationController alloc] initWithRootViewController:secondVC];
navController2.title = @"Second Tab";
navController2.tabBarItem.image = [UIImage imageNamed:@"second.png"];
NSArray *array = [[NSArray alloc] initWithObjects:navController1,navController2, nil];
UITabBarController *tabBarController = [[UITabBarController alloc] init];
tabBarController.tabBarItem.imageInsets = UIEdgeInsetsMake(0, -50, 0, 50);
tabBarController.viewControllers = array;
[self.window setRootViewController:tabBarController];
self.window.backgroundColor = [UIColor whiteColor];
[self.window makeKeyAndVisible];
return YES;
有人可以帮忙吗?