I have a long press gesture set on a UITableView
that presents a UIAlertController
containing the cell\'s text. When the UIAlertController
For some reason, both pieces of code are executing in the
if
That should have rung alarm bells for me. It is impossible that both the if
and the else
should run. This code must be running twice.
That is because you are not testing the state of the gesture recognizer. A long press g.r. sends its action message twice. You are running this code both on the long press and on the release. You need to test the state of the g.r. so that you don't do that. Example:
@IBAction func longPressedView(g: UIGestureRecognizer) {
if g.state == .Began {
// ... do it all here
}
}