I have a problem with UIView that I add to the bottom of the screen and animate it to fill most of the screen if a button is clicked. The view will animate up and down and rotate as intended. If I try to animate in the landscape, it breaks and gives me an error message:
*** Assertion failure in -[UIScrollView _edgeExpressionInContainer:vertical:max:], /SourceCache/UIKit_Sim/UIKit-2380.17/NSLayoutConstraint_UIKitAdditions.m:2174
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Autolayout doesn't support crossing rotational bounds transforms with edge layout constraints, such as right, left, top, bottom. The offending view is: <UIView: 0x9199340; frame = (20 0; 748 1024); transform = [0, -1, 1, 0, 0, 0]; autoresize = RM+BM; layer = <CALayer: 0x91993d0>>'
Representation of violation - self.view.
How do I create a UIView:
[self.myContentView addSubview:subBar.filterListView];
[self.myContentView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|[filterListView]|"
options:0
metrics:nil
views:@{@"filterListView": subBar.filterListView}]];
subBar.filterListView.bottomConstraint = [NSLayoutConstraint constraintWithItem:subBar.filterListView
attribute:NSLayoutAttributeBottom
relatedBy:NSLayoutRelationEqual
toItem:self.mapView
attribute:NSLayoutAttributeBottom
multiplier:1
constant:0];
subBar.filterListView.topConstraint = [NSLayoutConstraint constraintWithItem:subBar.filterListView
attribute:NSLayoutAttributeTop
relatedBy:NSLayoutRelationEqual
toItem:self.mapView
attribute:NSLayoutAttributeBottom
multiplier:1
constant:0];
[self.myContentView addConstraint:subBar.filterListView.bottomConstraint];
[self.myContentView addConstraint:subBar.filterListView.topConstraint];
self.myContentView is a UIView that handles all self.view:
[self.view addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|[contentView]|"
options:0
metrics:nil
views:NSDictionaryOfVariableBindings(contentView)]];
[self.view addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|[contentView]|"
options:0
metrics:nil
views:NSDictionaryOfVariableBindings(contentView)]];
To animate subBar.filterListView, I remove the upper and lower limit, reassign them, add and animate:
[self.myContentView removeConstraint:view.topConstraint];
[self.myContentView removeConstraint:view.bottomConstraint];
view.topConstraint = [NSLayoutConstraint constraintWithItem:view
attribute:NSLayoutAttributeTop
relatedBy:NSLayoutRelationEqual
toItem:self.topToolBar
attribute:NSLayoutAttributeBottom
multiplier:1
constant:0];
view.bottomConstraint.constant -= SUB_BAR_SIZE.height;
[self.myContentView addConstraint:view.topConstraint];
[self.myContentView addConstraint:view.bottomConstraint];
[self.myContentView setNeedsUpdateConstraints];
[UIView animateWithDuration:.25 animations:^{
[self.myContentView layoutIfNeeded];
}];
Is the code tangled up and down when it rotates? Does he think that the top of the portrait is a landscape?