I have a custom UITableViewCell
with UITextView
, UICollectionView
and UITableView
inside. They have a 10 px space between. In some cases I have only UITextView
, sometimes only collection view etc.
When no text - I have to move UICollection view up by 10 px. And If I have no text, tableView and collectionView it should be zero height.
- (void)configureMiddleWrapperState
{
self.middleWrapperHasNote = self.noteTextView.text.length > 0;
self.noteTextViewTopConstraint.constant = self.middleWrapperHasNote ? 7.f : 0.f;
self.staffWrapperTopConstraint.constant = self.middleWrapperHasStaff ? 7.f : 0.f;
self.tagsWrapperTopConstraint.constant = self.middleWrapperHasTags ? 7.f : 0.f;
BOOL middleWrapperHasAtleastOne = self.middleWrapperHasNote || self.middleWrapperHasStaff ||
self.middleWrapperHasTags;
self.middleWrapperLastTenPixelSpaceConstraint.constant = middleWrapperHasAtleastOne ? 7.f : 0.f;
[self setNeedsUpdateConstraints];
}
- (void)layoutSubviews
{
[super layoutSubviews];
[self setExcludedPaths];
[self configureMiddleWrapperState];
}
The result isn't like expected:
instead of one line.
When only text is looks like expected.
Constraints become work only if I scroll up and down many times.