Well, I know that there is already many answers to my questions but I've tested each one of these and I still have the problem. I have a UIScrollView wich contains a UIView, I want active autolayout for an animation. But because of this, my scrollview doesn't scroll.
This is my code :
NSDictionary *viewsDictionary = NSDictionaryOfVariableBindings(_scrollView, _containerScrollView);
[_scrollView setScrollEnabled:YES];
[_scrollView setContentSize:CGSizeMake(_scrollView.frame.size.width, CGRectGetHeight(_containerScrollView.frame))];
_scrollView.userInteractionEnabled = YES;
_scrollView.delaysContentTouches = YES;
[self.superview addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|[_scrollView]|" options:0 metrics:0 views:viewsDictionary]];
[self.superview addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|[_scrollView]|" options:0 metrics:0 views:viewsDictionary]];
[_scrollView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|[_containerScrollView]|" options:0 metrics:0 views:viewsDictionary]];
[_scrollView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|[_containerScrollView]|" options:0 metrics:0 views:viewsDictionary]];
Somebody can explain me why doesn't it work ?
contentSize
of a scroll view, because it is generally dictated by the constraints of the subviews. But, stepping back from that, perhaps you can just tell us what you're trying to achieve. It's hard to recommend solutions without understanding the bigger picture of the desired UX. E.g., what is the nature of the animation? How did you define the constraints of_containerScrollView
(which I assume is aUIView
inside the scroll view, not aUIScrollView
itself)? – Rob