Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I had the pin drag working but was trying to figure out why the pin annimations that occur when you don't override setDragState - no longer work in my implementation. Your question contained my answer .. Thanks!</p> <p>Part of the problem with your code is that once you override the setDragState function, per the xcode documentation, you are responsible for updating the dragState variable based on the new state coming in. I would also be a little concerned about your code calling itself (setDragState calling [self setDragState]).</p> <p>Here is the code I ended up (with your help) that does all of the lifts, drags and drops as I expect them to occur. Hope this helps you too!</p> <pre><code>- (void)setDragState:(MKAnnotationViewDragState)newDragState animated:(BOOL)animated { if (newDragState == MKAnnotationViewDragStateStarting) { // lift the pin and set the state to dragging CGPoint endPoint = CGPointMake(self.center.x,self.center.y-20); [UIView animateWithDuration:0.2 animations:^{ self.center = endPoint; } completion:^(BOOL finished) { self.dragState = MKAnnotationViewDragStateDragging; }]; } else if (newDragState == MKAnnotationViewDragStateEnding) { // save the new location, drop the pin, and set state to none /* my app specific code to save the new position objectObservations[ACTIVE].latitude = pinAnnotation.coordinate.latitude; objectObservations[ACTIVE].longitude = pinAnnotation.coordinate.longitude; posChanged = TRUE; */ CGPoint endPoint = CGPointMake(self.center.x,self.center.y+20); [UIView animateWithDuration:0.2 animations:^{ self.center = endPoint; } completion:^(BOOL finished) { self.dragState = MKAnnotationViewDragStateNone; }]; } else if (newDragState == MKAnnotationViewDragStateCanceling) { // drop the pin and set the state to none CGPoint endPoint = CGPointMake(self.center.x,self.center.y+20); [UIView animateWithDuration:0.2 animations:^{ self.center = endPoint; } completion:^(BOOL finished) { self.dragState = MKAnnotationViewDragStateNone; }]; } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload