ios - how to display a new tableview from user selecting row in tableview swift -
i trying figure how segue new view when user selects row in current tableview. thinking done didselectrowatindexpath method can not figure out logic of how work. display view specific courses in subject user selected. think use array? appreciate here thanks.
yes, you're right, can responding didselectrowatindexpath.
you can have view controller table view delegate implements these methods:
func tableview(tableview: uitableview, didselectrowatindexpath indexpath: nsindexpath) { if let thing = self.things.objectatindex(indexpath.row) as? thing { self.performseguewithidentifier("openthing", sender: thing) } }
where "openthing" segue defined in storyboard.
then have overridden prepareforsegue method:
override func prepareforsegue(segue: uistoryboardsegue, sender: anyobject?) { if segue.identifier == "openthing" { if let controller = segue.destinationviewcontroller as? thingviewcontroller { if let thing = sender as? thing { controller.thing = thing } } } }
this contrived example of having array of "things". access thing row index segue next view controller, providing thing want display.
Comments
Post a Comment