ios - How to add two navigationController in a viewController? -
i add 2 navigationcontrollers in viewcontroller. these 2 navigationcontroller totaly independent , not linked. display these 2 navigationviewcontroller 1 beside other, splitviewcontroller.
with childviewcontroller, succeed add 2 viewcontrollers position , size want. when try navigationcontroller, take screen , display @ point (0,0). try change frame of navigationcontroller nothing changed.
can me please?
thanks lot.
edit : here code used add childvc :
self.meetingslistviewcontroller = [[meetingslistviewcontroller alloc] initwithnibname:@"meetingslistviewcontroller" bundle:nil]; self.navcalendar = [[uinavigationcontroller alloc] initwithrootviewcontroller:meetingslistviewcontroller]; [self.navcalendar setnavigationbarhidden:no]; self.meetingslistviewcontroller.view.frame = cgrectmake(10, 54, self.view.frame.size.width/2-20, self.view.frame.size.height - 64); self.navcalendar.view.frame = self.meetingslistviewcontroller.view.frame; self.navcalendar.view.autoresizessubviews = no; [self addchildviewcontroller:meetingslistviewcontroller]; [self.view addsubview:self.meetingslistviewcontroller.view]; [self.navcalendar didmovetoparentviewcontroller:self]; self.listplaylistviewcontroller = [[listplaylistviewcontroller alloc] initwithnibname:@"listplaylistviewcontroller" bundle:nil]; self.navplaylist = [[uinavigationcontroller alloc] initwithrootviewcontroller:listplaylistviewcontroller]; [self.navplaylist setnavigationbarhidden:no]; self.listplaylistviewcontroller.view.frame = cgrectmake(self.view.frame.size.width/2+10, 54, self.view.frame.size.width/2-20, self.view.frame.size.height - 64); self.navplaylist.view.frame = self.listplaylistviewcontroller.view.frame; self.navplaylist.view.autoresizessubviews = no; [self addchildviewcontroller:listplaylistviewcontroller]; [self.view addsubview:self.listplaylistviewcontroller.view]; [self.navplaylist didmovetoparentviewcontroller:self];
the easy way add 2 container views controller's view in storyboard, give 2 embedded controllers. think should able select these embedded controllers , use menu embed them in navigation controller. if doesn't work, delete embedded controllers, drag out navigation controller, add control drag container view embed them.
after edit:
if want in code, there several things wrong you've posted. addchildviewcontroller, addsubview, , didmovetoparentviewcontroller calls should made navigation controllers, not content controllers. there's no need set frame of content controllers, set frame of navigation controllers directly:
self.meetingslistviewcontroller = [[uiviewcontroller alloc] initwithnibname:@"meetingslistviewcontroller" bundle:nil]; self.navcalendar = [[uinavigationcontroller alloc] initwithrootviewcontroller:self.meetingslistviewcontroller]; self.navcalendar.view.frame = cgrectmake(10, 54, self.view.frame.size.width/2-20, self.view.frame.size.height - 64); [self addchildviewcontroller:self.navcalendar]; [self.view addsubview:self.navcalendar.view]; [self.navcalendar didmovetoparentviewcontroller:self]; self.listplaylistviewcontroller = [[uiviewcontroller alloc] initwithnibname:@"listplaylistviewcontroller" bundle:nil]; self.navplaylist = [[uinavigationcontroller alloc] initwithrootviewcontroller:self.listplaylistviewcontroller]; self.navplaylist.view.frame = cgrectmake(self.view.frame.size.width/2+10, 54, self.view.frame.size.width/2-20, self.view.frame.size.height - 64); [self addchildviewcontroller:self.navplaylist]; [self.view addsubview:self.navplaylist.view]; [self.navplaylist didmovetoparentviewcontroller:self];
Comments
Post a Comment