The indexPath of custom table cell is undefined, objective c -
i have created custom cell call pendingdoctortableviewcell , used in pendingdoctortableview. work find , added disclosure indicator using
[cell setaccessorytype:uitableviewcellaccessorydetaildisclosurebutton];
it's able performed segue "showpendingdoctor".
however when used prepareforsegue, indexpath undefined.
- (void)prepareforsegue:(uistoryboardsegue *)segue sender:(id)sender { if ([segue.identifier isequaltostring:@"showpendingdoctor"]) { nsindexpath *indexpath = [self.tableview indexpathforselectedrow]; actionforpendingdoctorviewcontroller *destviewcontroller = segue.destinationviewcontroller; destviewcontroller.myobjects = [myobject objectatindex:indexpath.row]; // hide bottom tab bar in detail view // destviewcontroller.hidesbottombarwhenpushed = yes; } }
how can know row had been tap. because return object of 1st index.
anyone can me? i'm rushing project. thanks.
declare variable of nsindexpath save selected indexpath
nsindexpath *selectedindexpath;
use tableview delegate identify selected row , perform segue programmatically
-(void)tableview:(uitableview *)tableview didselectrowatindexpath: (nsindexpath *)indexpath { [self performseguewithidentifier:your_segue_identifier sender:self]; }
pass object next viewcontroller through prepareforsegue
-(void)prepareforsegue:(uistoryboardsegue *)segue sender:(id)sender { if ([segue.identifier isequaltostring:your_segue_identifier]) { actionforpendingdoctorviewcontroller *destviewcontroller = segue.destinationviewcontroller; destviewcontroller.myobjects = [myobject objectatindex:selectedindexpath.row]; } }
Comments
Post a Comment