Reputation: 4342
I have UIScrollview with dynamic views(Label, Imageview) inside it. I hide some views but white blank space is there. how can I remove it?
I tried with below code but it doesn't work,
[self.view addConstraint:[NSLayoutConstraint constraintWithItem:myView attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:0]];
The layout of File Like:
-View
-ScrollView
-UIImageView
-UIButton
-UIButton
-UILable
-UILable
-UIButton
-UILable
-UILable
Upvotes: 3
Views: 1968
Reputation: 570
Just hiding views won't help, as it still will take place. You have several options: 1. Each of views inside scrollView should have height constraint that should be set to 0 when hiding is required. Then you should call
[scrollView setNeedsLayout];
[scrollView layoutIfNeeded];
[viewToHide removeFromSuperview];
Upvotes: 1