UISearchBar 移动到屏幕顶部时未接收到触摸
我有一个 UISearchBar 作为 UIViewController 视图的子视图。 UIViewController 有一个导航栏。当我触摸 UISearchBar 时,我会启动一个动画,将导航栏向上移动到屏幕之外,并将搜索栏向上移动到导航栏的位置。
当我这样做时,属于搜索栏的取消按钮不会将触摸事件发送到搜索栏的委托。当我将搜索栏向上移动几个像素时,搜索栏取消按钮仍然有效。
关于我可能做错了什么有什么建议吗?
I have a UISearchBar as a subview of a UIViewController's view. The UIViewController has a navigation bar. When I touch on the UISearchBar, I initiate an animation that moves the navigation bar up and off of the screen and move the search bar up to be in place of the navigation bar.
When I do this, the cancel button belonging to the search bar does not send touch events to the search bar's delegate. When I move the search bar up a few pixels, the search bar cancel button still works.
Any suggestions on what I might be doing wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如何获取触摸事件(UIGestureRecognizers?)?您确定 UISearchBar 不在任何其他视图后面(可能具有透明背景)?这可能会导致您的触摸事件被发送到此覆盖视图。
另一个可能的问题可能是您将 UISearchBar 移出其超级视图。通过给它的超级视图一些背景颜色来检查。
How do you get the touch events (UIGestureRecognizers?)? Are you sure the UISearchBar is not behind any other view (maybe with a transparent background)? This might cause that your touch events are sent to this overlaying view.
Also possible issue might be you moved the UISearchBar out its super view. Check by giving its super view some backgroundColor.