ios - Swift Navigation with Drawer Controller -


i have following use case. using kydrawercontroller library. made drawer menu , working nicely. mainviewcontroller uinavigationcontroller. on toolbar/navigation bar got hamburger icon open drawer menu. drawer menu has items , when user clicks it, should open screen.

in android 1 use fragments replace content when item selected, in case toolbar keeps hamburger icon , drawer controller can still opened.

how implement on swift, idea use uinavigationcontroller or there better alternative. requirements following.

  • when item selected, toolbar title has change , drawer menu must still accessible.
  • when item selected, content has replaced (with viewcontroller)
  • each 'content' view controller can lead subviews (detail/article view) in case hamburger icon should replaced button
  • should have no memory leaks

what best solution this? , have code example this.

as per there code, using uinavigationcontroller load selected menu option.

- (void)tableview:(uitableview *)tableview didselectrowatindexpath:(nsindexpath *)newindexpath{     [tableview deselectrowatindexpath:newindexpath animated:yes];      kydrawercontroller *eldrawer = (kydrawercontroller*)self.navigationcontroller.parentviewcontroller;     uiviewcontroller *viewcontroller;     switch ([newindexpath row]) {         case 0:{              viewcontroller = [[uistoryboard storyboardwithname:@"main" bundle:nil] instantiateviewcontrollerwithidentifier:@"vc1"];                              break;         }          case 1:{ viewcontroller = [[uistoryboard storyboardwithname:@"main" bundle:nil] instantiateviewcontrollerwithidentifier:@"vc2"];                break;         }          default:{             viewcontroller = [[uistoryboard storyboardwithname:@"main" bundle:nil] instantiateviewcontrollerwithidentifier:@"vc3"];                             break;         }         }      uinavigationcontroller *navcontroller=[[uinavigationcontroller alloc]initwithrootviewcontroller:viewcontroller];       eldrawer.mainviewcontroller=navcontroller;     [eldrawer setdrawerstate:drawerstateclosed animated:yes]; } 

controllers want load side menu, need add leftbarbutton item drawer button. in button's selector, need add following line of code.

- (ibaction)clickedopen:(id)sender {      kydrawercontroller *eldrawer = (kydrawercontroller*)self.navigationcontroller.parentviewcontroller;     [eldrawer setdrawerstate:drawerstateopened animated:yes]; } 

Comments

Popular posts from this blog

Sort a complex associative array in PHP -

vb.net - How to ignore if a cell is empty nothing -

recursion - Can every recursive algorithm be improved with dynamic programming? -