使用滑动或手势隐藏 uitableview

hide uitableview with swipe or gesture

我正在 swift 上制作导航应用程序,我有一个半视图 - mapView,和一个下半部分 - tableView。我正在寻找一种通过向下滑动来隐藏 tableView 的方法(向下滑动 tableView 的顶部,它就会消失。我找到了一种如何用动画隐藏它的方法,但我不知道如何通过滑动来完成这个动作,没有任何与 mapView 冲突。有什么想法或建议吗?

您需要创建一个 UISwipeGestureRecognizer 并将其添加到 UITableView
尝试以下操作:

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)

选择器 func 如下所示:

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