ios - Tableview to Tableview -
i complete novice coding , app building apologies beforehand if has easy solution. have created app has tab bar @ bottom , tableview on 1 of tabs. have populated cells in tableview.
i looking able select cell , go tableview different categories based on cell selection. e.g. first table view: dogs, snakes, rabbits. second table view: labrador, shitzu, poodle (if 'dogs' cell selected) python, cobra, rattlesnake (if 'snakes' cell selected). etc.
you'll want embed these 2 tableviewcontrollers in navigation controller.
you can in storyboard:
select
tableviewcontrollerfirst table in itin xcode's menu bar: editor > embed in > navigation controller
create
tableviewcontrollerin storyboard.ctrl+drag storyboard segue
tableviewcellon firsttableviewcontrollersecondtableviewcontroller. @hw731 said, indicate when cell tapped invoke segue new tableviewcontroller.
--now move code.
in .m file first view controller can pass whatever data want pass second vc. (like, fact chose dog)
in
-(void)prepareforsegue:(uistoryboardsegue *)segue sender:(id)sendermethod:- grab reference second view controller so:
secondtableviewcontroller *secondtablevc = segue.destinationviewcontroller - now can
secondtablevc.arrayofitemstodisplay = dogsarray;
- grab reference second view controller so:
there interim steps in there creating class second tableviewcontroller , connecting it. hope helps!
Comments
Post a Comment