我有一个带有嵌入式导航 Controller 的 View Controller ,我希望呈现的 Controller 能够在任何地方滑动以返回到根 Controller 。这怎么可能是通过使用 SwipeGesture 或扩展导航 Controller ?
另请注意,所呈现的 Controller 是一个表格 View 并且具有单元格 Nib 。
最佳答案
根据您的指示,您的 tableview 上的普通手势识别器就足够了。
我会做这样的事情:
override func viewDidLoad() {
super.viewDidLoad()
let gesture = UISwipeGestureRecognizer(target: self, action: #selector(dismiss(fromGesture:)))
tableView.addGestureRecognizer(gesture)
}
@objc func dismiss(fromGesture gesture: UISwipeGestureRecognizer) {
//Your dismiss code
//Here you should implement your checks for the swipe gesture
}
如果您想禁用后退手势的默认行为:
navigationController?.interactivePopGestureRecognizer?.isEnabled = false
希望对您有所帮助。 :)
关于Swift Navigation Controller 轻扫以返回任何地方,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43235219/