uitableview - ios - naming and make action from each cell -
so i'm using code... "mfsidemenudemostoryboard" https://github.com/mikefrederick/mfsidemenu/tree/master/demos/mfsidemenudemostoryboard/mfsidemenudemostoryboard
and want give name each cell in "sidemenuviewcontroller.m" , make each 1 of these cells show specific uiview in "demoviewcontroller.m". ?
any appreciated, thank you!!
in sidemenucontroller
- (void)tableview:(uitableview *)tableview didselectrowatindexpath:(nsindexpath *)indexpath { demoviewcontroller *democontroller = [[demoviewcontroller alloc] initwithnibname:@"demoviewcontroller" bundle:nil]; democontroller.title = [nsstring stringwithformat:@"demo #%d-%d", indexpath.section, indexpath.row]; uinavigationcontroller *navigationcontroller = self.menucontainerviewcontroller.centerviewcontroller; nsarray *controllers = [nsarray arraywithobject:democontroller]; navigationcontroller.viewcontrollers = controllers; [self.menucontainerviewcontroller setmenustate:mfsidemenustateclosed];
}
replace code like:
- (void)tableview:(uitableview *)tableview didselectrowatindexpath:(nsindexpath *)indexpath { //edit #1 uinavigationcontroller *navigationcontroller = self.menucontainerviewcontroller.centerviewcontroller; demoviewcontroller *currentcenterview = [[navigationcontroller viewcontrollers] firstobject]; [currentcenterview addanotherview:indexpath.row]; //this tell 'middle view' load uiview ... can use indexpath.row determine option tapped , act accordingly. [self.menucontainerviewcontroller setmenustate:mfsidemenustateclosed];
}
you need add method - (void) addanotherview:(nsinteger ) row;
demoviewcontroller
or whatever you've called it.
edit #1 reference current loaded view. work if using 1 view controller on navigation controller stack. otherwise grabbing first object won't work , you'll need search right index.
Comments
Post a Comment