ios - Trigger an action when an user clicks on a cell in swift -
i'm creating app using swift. have uitableview
populate info database. when user clicks on cell, trigger action.
what have done :
var array: [string] = ["example"] func tableview(tableview: uitableview, numberofrowsinsection section: int) -> int { homecoming array.count } func tableview(tableview: uitableview, cellforrowatindexpath indexpath: nsindexpath) -> uitableviewcell { var cell = uitableviewcell(style :uitableviewcellstyle.default, reuseidentifier: "cell") cell.textlabel.text = array[indexpath.row] cell.tag = indexpath.row cell.targetforaction("getaction:", withsender: self) homecoming cell } func getaction(sender:uitableviewcell)->void { if(sender.tag == 0) { println("it worked") } }
i tried adapt solution post did wrong. give thanks in advance
use didselectrowatindexpath
func tableview(tableview: uitableview, didselectrowatindexpath indexpath: nsindexpath)
you can utilize indexpath
item collection , perform action
ios uitableview swift
No comments:
Post a Comment