Friday, 15 August 2014

swift - Master-Detail: UINavigatorController vs Storyboard Segue -



swift - Master-Detail: UINavigatorController vs Storyboard Segue -

scenario: master(tableview) --> detail. modus operandi: select row --> display detailvc

can see below, have mastervc embedded in uinavigationcontroller:

display detailvc via pushing uinavigationcontroller's vc stack:

override func tableview(tableview: uitableview, didselectrowatindexpath indexpath: nsindexpath) { println("tableview didselectrowatindexpath") allow storyboard = uistoryboard(name: "bliss", bundle: nil); allow controller = storyboard.instantiateviewcontrollerwithidentifier("diaryplayervc") diaryplayerviewcontroller self.navigationcontroller?.pushviewcontroller(controller, animated: true) }

works fine. however, 'prepareforseque' doesn't fire:

override func prepareforsegue(segue: uistoryboardsegue, sender: anyobject?) { if segue.identifier == "showdiaryplayer" { if allow indexpath = self.tableview.indexpathforselectedrow() { allow object = objects[indexpath.row] nsdate // (segue.destinationviewcontroller diaryplayerviewcontroller).detailitem = object } } }

understand have 2 (2) conflicting paradigms here: 1) using uinavigationcontroller vs 2) using storyboard relationship.

so... option 1: appears can remove segue link have storyboard stand-alone detailvc. option 2: via segue, i'm assuming can remove uinavigatorcontroller link.

i'm using alternative #1, launching detailvc via uinavigationcontroller.

question: if take alternative #2, how access (launch) detailvc ("diary player") master's row , hence, fire segue's 'prepareforsegue()'?

answer: create segue table view cell detail view controller.

swift uistoryboard master-detail

No comments:

Post a Comment