I need when the user presses the table cell to appear an alert with information.
Follow the code
import UIKit
class MyTableViewController: UITableViewController {
override func viewDidLoad() {
super.viewDidLoad()
self.navigationItem.title = "Bem da Água"
}
override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
let linha = indexPath.row
println("Selecionou \(linha)")
let Gest = UILongPressGestureRecognizer(target: self, action: "showAlerta:")
self.view.addGestureRecognizer(Gest)
}
func showAlerta(sender: UILongPressGestureRecognizer){
if sender.state == UIGestureRecognizerState.Began {
var alerta = UIAlertController(title: "", message: "", preferredStyle: UIAlertControllerStyle.Alert)
let show = UIAlertAction(title: "Ok", style: UIAlertActionStyle.Default,handler:nil)
alerta.addAction(show)
presentViewController(alerta,animated:true,completion:nil)
}
}
}