1
I need that when the user presses the table cell an alert with information appears.
Follows 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)
}
}
}
Here returns me a bug guy in Identifier Cell
– Faro
I don’t know what your method is like, which is how you assemble your cell, so I made an assumption to define the variable
cell
.– Paulo Rodrigues
Exactly as you put it
– Faro
Can you specify the error better? I could not identify where exactly is the error you quoted.
– Paulo Rodrigues
Ignore that mistake, because it was an oversight that I had and was resolved.
– Faro