hide uitableview with swipe or gesture

1.6k Views Asked by At

I am making navigation app on swift, and I have a half view - mapView, and a bottom half - tableView. I am looking for a way to hide tableView with down swipe(swiping top of tableView down, and it disappears. I found a way how to hide it with animation, but I don't know how to make this action with swipe, without any conflict with mapView. Any ideas or some advices?

1

There are 1 best solutions below

4
On BEST ANSWER

You will need to create a UISwipeGestureRecognizer and have to add it to the UITableView.
Try the following:

let swipeGesture = UISwipeGestureRecognizer(target: self, action: "hideTableView:") //do that animation to hide the UITableView
swipeGesture.direction = .Down //Swiping down may come into conflict w/ the UITableView itself if it is scrollable, check it out.
tableView.addGestureRecognizer(swipeGesture)

The selector func looks the follwing:

func hideTableView(sender: UISwipeGestureRecognizer) {
    //do hidingAnimation
}