Ответ 1
Вам нужно реализовать метод делегата didSelectRowAtIndexPath
и поместить в него свой код обработки.
override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
//CODE TO BE RUN ON CELL TOUCH
}
Я новичок в быстрой и не запрограммированной в объективе C. Так что я новичок:-) пытаясь сделать что-то довольно простое. Свяжите ячейку таблицы со списком, чтобы вызвать метод в контроллере, например http://prntscr.com/4m9kf7
Edit:
У меня есть эти методы в моем MasterController
override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
override func tableView(tableView: UITableView, canEditRowAtIndexPath indexPath: NSIndexPath) -> Bool {
override func tableView(tableView: UITableView, commitEditingStyle editingStyle: UITableViewCellEditingStyle, forRowAtIndexPath indexPath: NSIndexPath) {
override func tableView(tableView: UITableView!, didSelectRowAtIndexPath indexPath: NSIndexPath!) {
Я добавил точки останова во всех 4 из них. и при нажатии на ячейку он не останавливается ни в одном из них. См. Снимок экрана:
Вам нужно реализовать метод делегата didSelectRowAtIndexPath
и поместить в него свой код обработки.
override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
//CODE TO BE RUN ON CELL TOUCH
}
Для Swift 4:
override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
print("row selected: \(indexPath.row)")
}