How can I capture the click action of a table row in Swift WatchKit?

I currently have a table with dynamic rows. When I run the object, the rows are displayed on the screen and even have a print animation, but xcode won't let me connect the table row as an IBAction to its controller. I cannot use segue in this case, it should be like clicking a button, but preferably on the whole table. I would prefer not to embed a button in it. Any help is appreciated, thanks!

+3


source to share


2 answers


You want to override the function table:didSelectRowAtIndex

. This is the method on WKInterfaceController

.



override func table(table: WKInterfaceTable, didSelectRowAtIndex rowIndex: Int) {

    //Handle row selection
}

      

+5


source


Updated to swift 3.1:

There is no need to use WKInterfaceTable because the function is now inside the UITableViewController.



override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {

    let ren : Int = indexPath.row

    print ("Row \(ren)")
}

      

0


source







All Articles