So i am trying to animate some layout constraints and am having miserable luck, i just dont see anything and then i get an error message saying how it can't simultaneously satisfy all constrains etc.
I am using a class called PullableView whose animation is using old style [UIView commitAnimation]
so i subclassed it and added in my code for what i believe would be for animating constraints...No such luck and attempting to animate it or even get it to do much of anything is proving to be difficult i just get "Unable to simultaneously satisfy constraints".. Problem is i am fairly new to this constraint business so i would not know where to start.
here is the error the other one is pretty much the same but for centerY.
"<NSLayoutConstraint:0x7c8a3a0 StyledPullableView:0x905a9b0.centerX == UIView:0x9054680.centerX>",
"<NSLayoutConstraint:0x7c6b480 StyledPullableView:0x905a9b0.centerX == UIView:0x9054680.centerX + 128>"
I of course do [pullRightView setTranslatesAutoresizingMaskIntoConstraints:NO];
before calling this
any help appreciated.
- (void)setOpenedForConstraints:(BOOL)op animated:(BOOL)anim
{
opened = op;
if (anim)
{
NSLayoutConstraint *constraintX = [NSLayoutConstraint constraintWithItem:self
attribute:NSLayoutAttributeCenterX
relatedBy:NSLayoutRelationEqual
toItem:_parentView
attribute:NSLayoutAttributeCenterX
multiplier:1
constant:0];
NSLayoutConstraint *constraintY = [NSLayoutConstraint constraintWithItem:self
attribute:NSLayoutAttributeCenterY
relatedBy:NSLayoutRelationEqual
toItem:_parentView
attribute:NSLayoutAttributeCenterY
multiplier:1
constant:0];
[_parentView addConstraint:constraintX];
[_parentView addConstraint:constraintY];
constraintX.constant = opened ? self.openedCenter.x : self.closedCenter.x;
constraintY.constant = opened ? self.openedCenter.y : self.closedCenter.y;
}
if (anim)
{
// For the duration of the animation, no further interaction with the view is permitted
dragRecognizer.enabled = NO;
tapRecognizer.enabled = NO;
//[UIView commitAnimations];
[UIView animateWithDuration:animationDuration
animations:^
{
[self layoutIfNeeded];
}];
}
else
{
if ([delegate respondsToSelector:@selector(pullableView:didChangeState:)])
{
[delegate pullableView:self didChangeState:opened];
}
}
}