我已经在这个问题上工作了一段时间,但找不到解决我的问题的方法。
我有一个标签栏视图控制器,我试图用图像自定义,我有自定义图形工作但是我需要使用代码来显示和初始化标签栏的视图控制器。我也有在我的一个选项卡顶部显示导航栏的问题,我认为这与我如何启动选项卡视图控制器有关
情节提要显示药物选项卡顶部应该有一个导航栏,并且视图通过 segue 连接到选项卡栏,您可以看到我尝试使用情节提要连接将我的视图控制器链接到选项卡栏控制器. 我在 MedicationViewController.m 中有以下代码
/
// MedicationViewController.m
// fibromapp
//
// Created by jamie mcallister on 08/09/2013.
// Copyright (c) 2013 Jamie McAllister. All rights reserved.
//
#import "MedicationViewController.h"
#import "TakenViewController.h"
#import "MedsListViewController.h"
#import "MedsAlarmViewController.h"
@interface MedicationViewController ()
@end
@implementation MedicationViewController
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
TakenViewController *viewController2 = [[TakenViewController alloc] init];
MedsListViewController *viewController1 = [[MedsListViewController alloc] init];
MedsAlarmViewController *viewController3 = [[MedsAlarmViewController alloc] init];
self.viewControllers = [NSArray arrayWithObjects:viewController1,
viewController2,
viewController3,nil];
UITabBarItem *tab1 = [[UITabBarItem alloc] initWithTitle:@"Medication" image:[UIImage imageNamed:NULL] tag:1];
UITabBarItem *tab2 = [[UITabBarItem alloc] initWithTitle:@"Taken" image:[UIImage imageNamed:NULL] tag:2];
UITabBarItem *tab3 = [[UITabBarItem alloc] initWithTitle:@"Alarms" image:[UIImage imageNamed:NULL] tag:3];
UIImage* sel = [UIImage imageNamed:@"fmtabSel"];
[viewController1 setTabBarItem:tab1];
[viewController2 setTabBarItem:tab2];
[viewController3 setTabBarItem:tab3];
UIImage* tabBarBackground = [UIImage imageNamed:@"fmtab.png"];
UITabBar *tabBar = self.tabBar;
[tabBar setBackgroundImage:tabBarBackground];
[tabBar setSelectionIndicatorImage:sel];
}
return self;
}
- (void)viewDidLoad
{
UITabBar *tabbar = self.tabBar;
NSLog(@"%f %f", tabbar.frame.size.width, tabbar.frame.size.height);//used to find the size of the bar
[super viewDidLoad];
UIImage* tabBarBackground = [UIImage imageNamed:@"fmtab.png"];
UIImage* sel = [UIImage imageNamed:@"fmtabSel"];
UITabBar *tabBar = self.tabBar;
[tabBar setBackgroundImage:tabBarBackground];
[tabBar setSelectionIndicatorImage:sel];
// Do any additional setup after loading the view.
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end
使用此代码,我得到了选项卡,但此选项卡顶部没有导航栏。
有人可以建议我必须做些什么来解决这个问题吗?
如果您需要更多信息,请随时询问,我会将其编辑到这个问题的底部。提前致谢 :)