ios - UITableViewCell Segue not Working -
i'm making app have uitableview user adds data to, , want user able tap on cell , see more details cell chose. set segue cell celldetailcontroller later add details of cell chose. when run app , try tap on cell segue, selects cell , nothing happens. doing wrong here? here storyboard set up:
(i cant upload pictures yet here's link) http://tinypic.com/r/2ivcwsj/8
heres code class connected tableview:
import uikit typealias eventtuple = (name: string, date: string) var eventlist : [eventtuple] = [] class tableviewcontroller: uiviewcontroller, uitableviewdelegate { @iboutlet weak var eventtable: uitableview! override func viewdidload() { super.viewdidload() } override func viewdidappear(animated: bool) { eventtable.reloaddata() } override func didreceivememorywarning() { super.didreceivememorywarning() // dispose of resources can recreated. } // mark: - table view data source func tableview(tableview: uitableview, numberofrowsinsection section: int) -> int { // #warning incomplete method implementation. // return number of rows in section. return eventlist.count } func tableview(tableview: uitableview, cellforrowatindexpath indexpath: nsindexpath) -> uitableviewcell { let cell = uitableviewcell(style: uitableviewcellstyle.subtitle, reuseidentifier: "cell") cell.textlabel?.text = eventlist[indexpath.row].name cell.detailtextlabel?.text = eventlist[indexpath.row].date return cell } /* // override support editing table view. override func tableview(tableview: uitableview, commiteditingstyle editingstyle: uitableviewcelleditingstyle, forrowatindexpath indexpath: nsindexpath) { if editingstyle == .delete { // delete row data source tableview.deleterowsatindexpaths([indexpath], withrowanimation: .fade) } else if editingstyle == .insert { // create new instance of appropriate class, insert array, , add new row table view } } */ /* // override support rearranging table view. override func tableview(tableview: uitableview, moverowatindexpath fromindexpath: nsindexpath, toindexpath: nsindexpath) { } */ /* // override support conditional rearranging of table view. override func tableview(tableview: uitableview, canmoverowatindexpath indexpath: nsindexpath) -> bool { // return no if not want item re-orderable. return true } */ // mark: - navigation // in storyboard-based application, want little preparation before navigation override func prepareforsegue(segue: uistoryboardsegue, sender: anyobject?) { if(segue.identifier == "showdetailsegue") { } } }
drag segue tableviewcontroller (the yellow icon on top of viewcontroller), not tablecell. give segue identifier.
override didselectrowatindexpath
, perform segue here via performseguewithidentifier()
override func tableview(tableview: uitableview, didselectrowatindexpath indexpath: nsindexpath) { // pass object parameter, i.e. tapped row performseguewithidentifier("showdetailsegue", sender: indexpath.row) }
Comments
Post a Comment