我有一个UIViewController ,它使用segmentedControl在MKMapView和UITableView控制器之间切换。 地图显示了一些位置,然后切换到列表将以列表形式显示。
当切换segmentedControl ,它将显示相应的视图并隐藏另一个视图。
我遇到的一个非常奇怪的问题是,当显示tableView并向下滚动时,它有时会停止滚动,我只能向上和向下滑动手指并且tableView不会移动。 但是,然后我切换到地图,它已移动到另一个位置。 因此,当我滚动隐藏的mapView时,我意识到不知何故正在接收这些触摸。
这怎么可能? 有没有办法防止这种情况?
I have a UIViewController that uses a segmentedControl to switch between a MKMapView and a UITableView controller. The map shows some locations, then switching to list will show those in list form.
When toggling the segmentedControl it will show the corresponding view and hide the other.
The extremely strange issue I am having is, when showing the tableView and scrolling down, it sometimes stops scrolling and I can just swipe my finger up and down and the tableView does not move. However, I then switch to the map, and it has moved to another location. So I am realizing that somehow when scrolling my hidden mapView is receiving those touches.
How is this possible? And is there a way to prevent this?
最满意答案
您通过将hidden属性设置为1来隐藏视图,对吧? iOS也将隐藏着低于0.02的alpha视图视为隐藏。 如果您正确地将其设置为隐藏,则不会绘制视图,也不应接收任何触摸事件 - 您确定其他内容未在此处发挥作用吗?
你是否覆盖了MKMapView的touchesBegan方法,看看地图视图在隐藏时是否肯定会接收到触摸?
也许尝试将hidden设置为1 并将要隐藏的视图的alpha属性设置为0 。 如果问题仍然存在,那么肯定会发生其他事情,因为隐藏的视图根本没有被绘制到屏幕上,因此系统不会转发任何触摸事件。
I figured it out. The issue was a custom callout. When that was open on the map, and I toggled the map hidden, and showed the tableView, somehow that callout was still receiving touches, which would then scroll the map with it.
Hiding the callout at the same time as the map solved the issue.
当滚动顶部的UITableview时,隐藏的MKMapView以某种方式接收触摸(Hidden MKMapView is somehow receiving touches when scrolling UITableview that is on top)我有一个UIViewController ,它使用segmentedControl在MKMapView和UITableView控制器之间切换。 地图显示了一些位置,然后切换到列表将以列表形式显示。
当切换segmentedControl ,它将显示相应的视图并隐藏另一个视图。
我遇到的一个非常奇怪的问题是,当显示tableView并向下滚动时,它有时会停止滚动,我只能向上和向下滑动手指并且tableView不会移动。 但是,然后我切换到地图,它已移动到另一个位置。 因此,当我滚动隐藏的mapView时,我意识到不知何故正在接收这些触摸。
这怎么可能? 有没有办法防止这种情况?
I have a UIViewController that uses a segmentedControl to switch between a MKMapView and a UITableView controller. The map shows some locations, then switching to list will show those in list form.
When toggling the segmentedControl it will show the corresponding view and hide the other.
The extremely strange issue I am having is, when showing the tableView and scrolling down, it sometimes stops scrolling and I can just swipe my finger up and down and the tableView does not move. However, I then switch to the map, and it has moved to another location. So I am realizing that somehow when scrolling my hidden mapView is receiving those touches.
How is this possible? And is there a way to prevent this?
最满意答案
您通过将hidden属性设置为1来隐藏视图,对吧? iOS也将隐藏着低于0.02的alpha视图视为隐藏。 如果您正确地将其设置为隐藏,则不会绘制视图,也不应接收任何触摸事件 - 您确定其他内容未在此处发挥作用吗?
你是否覆盖了MKMapView的touchesBegan方法,看看地图视图在隐藏时是否肯定会接收到触摸?
也许尝试将hidden设置为1 并将要隐藏的视图的alpha属性设置为0 。 如果问题仍然存在,那么肯定会发生其他事情,因为隐藏的视图根本没有被绘制到屏幕上,因此系统不会转发任何触摸事件。
I figured it out. The issue was a custom callout. When that was open on the map, and I toggled the map hidden, and showed the tableView, somehow that callout was still receiving touches, which would then scroll the map with it.
Hiding the callout at the same time as the map solved the issue.
发布评论