ios - Do I need to embed a UINavigationController & Programmatically add UINavigationBar? -
i don't see of navigation bar. there outline of nav bar be. set navigationbar color , tint colors define nav bar if had no items.
- i used storyboards make functional ui.
my story board ui includes delegates,custom collection view cells,custom table view cells,and animations.
by end of app wanted add nav bars programmatically each of viewcontrollers. (see code)
i have used code in 6 other classes. , have 6 flawless navigation bars in viewcontrollers.
- (void)viewdidload { [super viewdidload]; uitapgesturerecognizer *tapgesture = [[uitapgesturerecognizeralloc] initwithtarget:self action:@selector(titlegesturelabelmethod)]; uilabel * titleview = [uilabel new]; titleview.text = @"title"; titleview.textcolor = [uicolor greencolor]; [titleview sizetofit]; titleview.userinteractionenabled = yes; [titleview addgesturerecognizer:tapgesture]; self.navigationitem.titleview = titleview; [self.view addsubview:titleview]; [self.navigationcontroller.navigationbar settranslucent:no]; uibarbuttonitem *lbutton = [[uibarbuttonitem alloc] initwithtitle:@"l" style:uibarbuttonitemstyleplain target:sel action:@selector(lbuttonmethod)]; [self.navigationitem setleftbarbuttonitem:lbutton animated:yes]; uibarbuttonitem *rbutton = [[uibarbuttonitem alloc] initwithtitle:@"r" style:uibarbuttonitemstyleplain target:self action:@selector(rbuttonmethod)]; [self.navigationitem setrightbarbuttonitem:rbutton animated:yes]; self.navigationcontroller.navigationbar.tintcolor = [uicolor redcolor]; [self.navigationcontroller.navigationbar setbartintcolor:[uicolor greencolor]]; [self.view addsubview:testtwonavbar]; }
you need embed view controller navigation controller. if you're using interface builder, storyboard select view controller. in menu select editor , choose embed in navigation controller. it's hard understand need though question.
Comments
Post a Comment