Note that there are some explanatory texts on larger screens.

plurals
  1. POAnimate two UIViews at the same time (sticking together)
    text
    copied!<p>i have searched a lot here but can't seem to find the answer to my question...</p> <p>I have a class called SubView, this class has a simple ability, it can show up or dissapear animated</p> <p>it does it like this:</p> <pre><code>-(void)showAnimated:(BOOL)animated { self.active = YES; //Make topmost [self.parentView bringSubviewToFront:self]; if (animated) { [UIView animateWithDuration:0.5 delay:0.0f options:UIViewAnimationCurveEaseInOut | UIViewAnimationOptionBeginFromCurrentState animations:^{ self.frame = self.originalFrame; if (self.panningBlock) { self.panningBlock(self.contentView.frame); } } completion:^(BOOL finished){ }]; } else { self.frame = self.originalFrame; if (self.panningBlock) { self.panningBlock(self.contentView.frame); } } </code></pre> <p>Where self.originalFrame has stored the original value of the position of the View, the hide portion if really similar</p> <pre><code>-(void)hideAnimated:(BOOL)animated { self.active = NO; //Store the frame CGRect _frame = self.frame; //Set the view starting point switch (self.showingLocation) { case SubViewShowingLocationRight: _frame.origin = CGPointMake(_frame.size.width, _frame.origin.y); break; case SubViewShowingLocationBottom: _frame.origin = CGPointMake(_frame.origin.x, _frame.size.height); break; case SubViewShowingLocationLeft: _frame.origin = CGPointMake(-_frame.size.width, _frame.origin.y); break; default: break; } if (animated) { [UIView animateWithDuration:0.5 delay:0.0f options:UIViewAnimationCurveEaseInOut | UIViewAnimationOptionBeginFromCurrentState animations:^{ self.frame = _frame; if (self.panningBlock) { self.panningBlock(self.contentView.frame); } } completion:^(BOOL finished){ }]; } else { self.frame = _frame; if (self.panningBlock) { self.panningBlock(self.frame); } } [self.delegate didDismissSubView:self]; </code></pre> <p>}</p> <p>//// So the animation occurs at self.frame = _frame and self.frame = self.originalFrame</p> <p>also i have self.panningBlock, that is a block that the parent view can give (it works so it can adjust himself to the frame change of the subview.. i.e. sub view has a picker, and it appears from bottom, i need to adjust the table view so it isn't obscured by the picker)</p> <p>An Example of what i do is</p> <pre><code>__weak MapViewController * weakSelf = self; [weakSelf.placesView setPanningBlock:^(CGRect _frame){ if (weakSelf.placesView.isActive) { CGRect mapFrame = weakSelf.mapView.frame; mapFrame.origin.x = _frame.origin.x + _frame.size.width; weakSelf.mapView.frame = mapFrame; } else { CGRect mapFrame = weakSelf.mapView.frame; mapFrame.origin.x = 0; weakSelf.mapView.frame = mapFrame; } }]; </code></pre> <p>Here the parent view moves right if the subview appear to give a push like animation</p> <p>That's all the code needed to understand (this is my first question, so forgive any rambling here)</p> <p>The point is that the animations won't occur at the same time, what happens is that the view that is entering enters a little more slow than the parent view they don't stick together, and i really don't know what to do...</p> <p>BTW: they do stick together the first time the animation occurs, but no more there after..</p> <p>any suggestions?</p> <p><strong>EDIT</strong> i now give some images as to explain what happens</p> <p><img src="https://i.stack.imgur.com/IzW9o.png" alt="screenshot 1"> <img src="https://i.stack.imgur.com/XxWLQ.png" alt="screenshot 2"></p>
 

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