ios - how link row in tableView to a segue -
i have 2 viewcontrollers, viewcontroller , tableviewcontroller. viewcontroller has button, when pressed tableviewcontroller start. tableviewcontoller contains 5 rows.
what trying is, when press rows should go viewcontroller. solve problem, can use unwindsegue, not know how have segue respond rows in table.
please let me know how make row in table linked segue
below code tableviewcontroller
code:
#import "tableviewcontroller.h" @interface tableviewcontroller () @property nsarray *tabledata; @end @implementation tableviewcontroller - (void)viewdidload { [super viewdidload]; // additional setup after loading view. self.tabledata = [nsarray arraywithobjects:@"android", @"ios", @"swift", @"objective-c", @"opencv",nil]; } - (void)didreceivememorywarning { [super didreceivememorywarning]; // dispose of resources can recreated. } -(nsinteger) tableview:(uitableview *)tableview numberofrowsinsection: (nsinteger)section { return [self.tabledata count]; } -(uitableviewcell *) tableview:(uitableview *)tableview cellforrowatindexpath:(nsindexpath *)indexpath { static nsstring *simpletableidentifier = @"simpletableitem"; uitableviewcell *cell = [tableview dequeuereusablecellwithidentifier:simpletableidentifier]; if (cell == nil) { cell = [[uitableviewcell alloc] initwithstyle:uitableviewcellstyledefault reuseidentifier:simpletableidentifier]; } cell.textlabel.text = [self.tabledata objectatindex:indexpath.row]; cell.imageview.image = [uiimage imagenamed:@"images.jpg"]; return cell; } -(void) tableview:(uitableview *)tableview didselectrowatindexpath: (nsindexpath *)indexpath { nslog(@"%li", indexpath.row); nslog(@"%@", [self.tabledata objectatindex:indexpath.row]); } @end
-(void) tableview:(uitableview *)tableview didselectrowatindexpath: (nsindexpath *)indexpath { if(indexpath.row % 2 == 0) { // row... } }
Comments
Post a Comment