I\'m developing an app for iOS and I\'m using the Storyboard with AutoLayout ON. One of my view controllers has a set of 4 buttons, and in certain circumstances i would like
This question is pretty old but the closet thing I've found is setting additional constraints (so the views around the "gone" view know what to do once it's missing)
A which you want to be A
| after setting B to gone |
B C
|
C
bConstraints
. Do this by:
bConstraints
.@IBOutlet var bConstraints: [NSLayoutConstraint]!
in your ViewControllerThen hide B
B.hidden = true
NSLayoutConstraint.deactivateConstraints(bConstraints)
To unhide
B.hidden = false
NSLayoutConstraint.activateConstraints(bConstraints)
Obviously the more and more views you have the more complex this grows, as you need additional constraints from each view
setHidden:TRUE/FALSE is the nearest equivalent to Android View.GONE/VISIBLE.
The View not necessarily take space if not visible!
I have made a ComboBox-Alike with a ListView laying on top of other views. I's only visible while selecting:
All of answers on this questions are inefficient.
Best way to equvailent of Android setVisibility:Gone method on iOS is that StackView
first select components then in editor, embed in, Stack View,
connect new stack view with IBOutlet, then:
hidden:
UIView * firstView = self.svViewFontConfigure.arrangedSubviews[0];
firstView.hidden = YES;
visibility:
UIView * firstView = self.svViewFontConfigure.arrangedSubviews[0];
firstView.hidden = NO;
as using stack view, all constraints will be keeped!
Document
https://github.com/tazihosniomar/LayoutManager
i hope it will help you .
Adding a constraint(NSLayoutAttributeHeight) that sets height of the view to 0 worked for me:
[self.view addConstraint:[NSLayoutConstraint constraintWithItem:self.captchaView attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:0]];
You can also clear the page, or at least certain cells of the page, and redefine the whole thing. It's fast and works well. I didn't write the code but found it in this pre-existing project I'm working on. Create ManagementTableSection
and ManagementTableCell
classes to manage it all. Sorry I can't provide better defined code.