ios - use storyboard with custom UITabbarController -
i have been working on issue time , cannot find solution problem.
i have tabbar view controller have tried customise images, have custom graphics working need use code display , init tabbar's view controllers. have problem displaying navigation bar @ top of 1 of tabs think connected how initiating tab view controllers
the storyboard shows there should navigation bar @ top of medication tab , view connected tab bar via segue can see have tried use storyboard segues link view controllers tab bar controller. have following code in medicationviewcontroller.m
/ // medicationviewcontroller.m // fibromapp // // created jamie mcallister on 08/09/2013. // copyright (c) 2013 jamie mcallister. 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 find size of bar [super viewdidload]; uiimage* tabbarbackground = [uiimage imagenamed:@"fmtab.png"]; uiimage* sel = [uiimage imagenamed:@"fmtabsel"]; uitabbar *tabbar = self.tabbar; [tabbar setbackgroundimage:tabbarbackground]; [tabbar setselectionindicatorimage:sel]; // additional setup after loading view. } - (void)didreceivememorywarning { [super didreceivememorywarning]; // dispose of resources can recreated. } @end with code tab there no navigation bar @ top of tab.
can suggest must resolve this?
if require more information feel free ask , edit bottom of question. in advance :)
if want navigation bar @ top should fill tabbar controller navigation controllers inited root controllers, not plain controllers. smth that:
takenviewcontroller *viewcontroller2 = [[takenviewcontroller alloc] init]; medslistviewcontroller *viewcontroller1 = [[medslistviewcontroller alloc] init]; medsalarmviewcontroller *viewcontroller3 = [[medsalarmviewcontroller alloc] init]; uinavigationcontroller * nc1 = [[uinavigationcontroller alloc] initwithrootviewcontroller:viewcontroller1]; uinavigationcontroller * nc2 = [[uinavigationcontroller alloc] initwithrootviewcontroller:viewcontroller2]; uinavigationcontroller * nc3 = [[uinavigationcontroller alloc] initwithrootviewcontroller:viewcontroller3]; self.viewcontrollers = [nsarray arraywithobjects:nc1, nc2, nc3,nil];
Comments
Post a Comment