I would like to use a long press gesture to toggle an .isHidden property of a tableView. My code (below) makes the tableView appear upon the first long press but does not hide it upon the second long press.
let recognizer = UILongPressGestureRecognizer()
var hideTableView = true
@IBAction func longPress(_ sender: Any) {
if recognizer.state == .began {
hideTableView = !hideTableView
}
if hideTableView {
tableView.isHidden = false
tableView.reloadData()
}
if !hideTableView {
tableView.isHidden = true
}
}
Any ideas appreciated!