Monday 15 August 2011

ios - View Controller Segue from didSelectRowAtIndexPath -



ios - View Controller Segue from didSelectRowAtIndexPath -

trying set 4 different segues triggered 4 different cells in uitableview segue different view controllers in app. main menu embedded in navigation controller. setup segues command dragging main menu view controller 4 different view controllers. in didselectrowatindexpath switch indexpath.row , instantiate segues method. problem i'm running sigabrt crash when segue performed. prepareforsegue called know segue beingness triggered it's causing crash can't seem figure out. code posted below, help appreciated, give thanks you.

-(void)tableview:(uitableview *)tableview didselectrowatindexpath:(nsindexpath *)indexpath { switch(indexpath.row) { case 0: break; case 1: { [self performseguewithidentifier:@"secondviewcontroller" sender:self]; //also tried passing in cell parameter "sender:" //doesnt work either. break; } //other segues performed in similar manner. case 2: break; case 3: break; case 4: break; case 5: break; } }

your segue configured "push" segue. means instance of secondviewcontroller pushed on navigation controller's navigation stack. (see push segues on apple's storyboard tutorial.)

however, table view controller isn't within navigation controller, impossible. (there's no stack of view controllers force on to.)

your simple choices:

change segue "show" (in xcode 6), or "modal" (in xcode 5) embed table view controller in navigation controller, there's stack force on to

more complex solutions involve building custom parent view controllers , defining custom transitions, i'm assuming that's not you're after.

some unrelated general information:

your effort alter "sender" doesn't matter. "sender" allow pass object want prepareforsegue:sender: method. parameter otherwise ignored. when crash, should read console, , stack trace. if can't figure out, include them on stack overflow question. my app crashed, what? first-class reading if you're new debugging stuff.

ios objective-c iphone uitableview swift

No comments:

Post a Comment