I have a custom annotation that sets its image based on the type of the annotation using the viewForAnnotation delegate method. Im only using 1 annotation that represents a car moving and want to change the image for when the car is detected to be moving and stopped. How could I go about this besides removing my annotation and re-adding it which causes a blink?
相关问题
- Core Data lightweight migration crashes after App
- How can I implement password recovery in an iPhone
- State preservation and restoration strategies with
- “Zero out” sensitive String data in Swift
- Get the NSRange for the visible text after scroll
相关文章
- 现在使用swift开发ios应用好还是swift?
- UITableView dragging distance with UIRefreshContro
- TCC __TCCAccessRequest_block_invoke
- Where does a host app handle NSExtensionContext#co
- Swift - hide pickerView after value selected
- Popover segue to static cell UITableView causes co
- How do you detect key up / key down events from a
- didBeginContact:(SKPhysicsContact *)contact not in
Wherever you detect that the car's state has changed, retrieve the annotation's current view using the
MKMapView
instance methodviewForAnnotation:
. This is not the same as themapView:viewForAnnotation:
delegate method.After getting the current view for the annotation, you can modify its properties including
image
.Also make sure the
mapView:viewForAnnotation:
delegate method has the same exact condition to setimage
based on the state of the car annotation. You may want to put the logic in a common method called from both places (where the state changes and the delegate method) so the code isn't duplicated.For example, where the state changes, you might have:
The
if
statement (or whatever logic you have to setimage
) is the part that should also be in theviewForAnnotation
delegate method.