Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个视图,顶部有一个搜索栏,List下面有一个 SwiftUI。我需要检测List滚动的时间,以便我可以关闭搜索栏键盘。List滚动时如何调用一些代码?谢谢!
List
我建议使用simultaneousGesture如下修饰符:
simultaneousGesture
List { // ... your list items } .simultaneousGesture(DragGesture().onChanged({ _ in // if keyboard is opened then hide it }))