Detect whether the user moves the map, or whether it is programmed by iOS Mapkit

Okay, I have a map loaded with pins from a remote JSON feed, and it is loaded into the application. Everything is ok.

Now , From the initial experiment, regionDidChangeAnimated is called multiple times, so I moved my post request to a method that uses the drag map gesture recognizer, and then executes the post request to get the data from the JSON feed and after deleting it Reload my map pin. This is also perfect.

Now my only problem is that if I select an annotation near the edge of the screen, the map will move slightly to accommodate the display of annotation annotations The problem is that regionDidChangeAnimated will be called when this happens, but my post request is not because I use a gesture recognizer to call it, so the map will not be interfered by the user but move the operating system. I don’t want to move my Post request To regionDidChangeAnimated because it is called multiple times but I want to know if there is a way to test if the user causes the map to move or it does it by itself to adapt to the annotations as described above. The regionDidChangeAnimated in the research I studied may be called more than The necessary number of times, so some guidance is good for how to prevent or detect user interaction with the operating system to move the map.

I have a similar question: I want to distinguish whether the display part of the map has been changed by the program or user interaction. Obviously, the MKMapView object does not tell me, that is, in both cases, the regionDidChangeAnimated is called without indicating the reason. But because MKMapView is a subclass of UIView and a subclass of UIResponder, the methods touchesBegan:withEvent: and touchesEnded:withEvent: can be implemented to find out if the map is touched during the change of the display area. If so, you can assume the display area The change is caused by user interaction. Of course, if you study the touch and event types of these methods more precisely, you can be more specific.

Okay, I have a map loaded The pin from the remote JSON feed is loaded into the application. Everything is normal.

Now, from the initial experiment, regionDidChangeAnimated is called multiple times, so I request my post Move to a method that uses the drag map gesture recognizer, Then perform a post request to get the data from the JSON feed and reload my map pin after deleting it. This is also perfect.

Now my only problem is if I choose one close to For annotations at the edge of the screen, the map will move slightly to accommodate the display of annotation annotations. The problem is that regionDidChangeAnimated will be called when this happens, but my post request is not because I use a gesture recognizer to call it, so the map will not be used by the user Intervene instead to move the operating system. I don’t want to move my Post request to regionDidChangeAnimated because it is called multiple times but I want to know if there is a way to test if the user causes the map to move or it does it by itself to adapt to the above, annotated The regionDidChangeAnimated in the research I studied may be called more than necessary, so some guidance is good for how to prevent or detect user interaction and the operating system to move the map.

< /p>

I have a similar question: I want to distinguish whether the display part of the map has been changed by the program or user interaction. Obviously, the MKMapView object does not tell me, that is, in both cases, the regionDidChangeAnimated is called without Indicate the reason. But because MKMapView is a subclass of UIView and a subclass of UIResponder, the methods touchesBegan:withEvent: and touchesEnded:withEvent: can be implemented to find out if the map is touched during the change of the display area. If so, you can It is assumed that the change of the display area is caused by user interaction. Of course, if you study the touch and event types of these methods more precisely, you can be more specific.

Leave a Comment

Your email address will not be published.