ios - UISwipeGestureRecognizer 可以用于 UIHostingController 中的视图吗?
问题描述
根据https://stackoverflow.com/a/64726641/3286489中的回答,我可以使用UISwipeGestureRecognizer
.
但是,当我将相同的代码传输到UIHostingController
下面时,它不再起作用
class ContextViewController: UIHostingController<CustomDrawViewWrapper> {
let drawViewWrapper: CustomDrawViewWrapper
init(drawView: CustomDrawView) {
self.drawViewWrapper = CustomDrawViewWrapper(drawView: drawView)
super.init(rootView: self.drawViewWrapper)
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
override func viewDidLoad() {
super.viewDidLoad()
view.isUserInteractionEnabled = true
let gesture = UISwipeGestureRecognizer(target: self, action: #selector(dismissVC))
gesture.direction = .down
view.addGestureRecognizer(gesture)
}
@objc
private func dismissVC() {
dismiss(animated: true)
}
}
我需要做些什么才能让向下滑动工作UIHostingController
?
UIHostingController
注意:如果不在全屏模式下,向下滑动以关闭仍然有效。
解决方案
推荐阅读
- rest - 我如何将一个 api 调用到另一个飞镖
- django - 更改 SmallPositiveIntegerField 的默认约束
- jquery - 如何使用 jquery 重置添加的字体大小?
- geometry - 计算两个矩形列表的重叠
- javascript - 如何使用 facebook api 2020 在 facebook 上创建活动?
- wordpress - 全局宽度不适用于基金会的新 XY 网格
- c# - 导致 object.child = null 对象失败的动态代理?
- r - 我怎样才能在R中制作这张桌子?
- c++ - CMake `target_link_libraries` 在非标准位置使用 PRIVATE 共享库
- java - GridBagLayout Swing 中的 JSpinners 和 JButton