gpt4 book ai didi

iOS swift : Propagates Swipe Events from nester controller to underneath controller

转载 作者:行者123 更新时间:2023-11-29 05:45:21 25 4
gpt4 key购买 nike

我有一个嵌套的 UIViewController 覆盖了屏幕的一半。

在此 Controller 下有父 ViewController。

我只想将横向滑动事件传播到底部(父) Controller 。

我想我应该使用以下函数

override func point(inside point: CGPoint, with event: UIEvent?) -> Bool {
return (my test)
})
}

但我也知道这个函数应该应用于 UIView,而不是 UIViewController。所以我陷入困境,我不知道如何继续。

最佳答案

您可以创建

class SomeView:UIView {
override func point(inside point: CGPoint, with event: UIEvent?) -> Bool {
return true/false
}
}

并将其分配给IB中子级的vc'view,您也可以在vc内部实现

override func touchesBegan(_ touches: Set<AnyHashable>, withEvent event: UIEvent) {
var touch: UITouch? = touches.first
//location is relative to the current view
// do something with the touched point
if touch?.view == childVC.view {
}
}

编辑:

要将滑动操作传播到父级,请添加委托(delegate)并将滑动操作传递给子级,并在触发时使用委托(delegate)通知父级

关于iOS swift : Propagates Swipe Events from nester controller to underneath controller,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56200734/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com