Open the-civilian opened 9 years ago
I got a similar issue. The view just does not show up...
This pull request does fix my issue: https://github.com/dzenbot/DZNEmptyDataSet/pull/133
It does? Thanks for checking @mknet Will test the PR a bit more. Sorry about this issue.
Yeah, it does. I am not into iOS development as you are, so I can barely say what this line does but it helps:
[self addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|[contentView]|" options:0 metrics:nil views:@{@"contentView": self.contentView}]];
I guess it resizes the "view port" of the view to the max even if there is no content. Am I right?
I expected the customView to take all available space by default. But when loading the view from a Nib it is not the case. I had to make the following change to make it work:
if (_customView) {
// -------- CODE CHANGE START -----
[_customView setTranslatesAutoresizingMaskIntoConstraints:NO]; /* default is !CGRectIsEmpty(view.frame) */
[self removeAllConstraints];
[self addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|[contentView]|" options:0 metrics:nil views:views]];
[self addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|[contentView]|" options:0 metrics:nil views:views]];
// -------- CODE CHANGE END -----
[views setObject:_customView forKey:@"customView"];
[self.contentView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|[customView]|" options:0 metrics:nil views:views]];
[self.contentView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|[customView]|" options:0 metrics:nil views:views]];
// Skips from any further configuration
return [super updateConstraints];;
}
This makes sense. I think that code was missed with one merge. Mind PR it?
Hi @dzenbot ,
Done, i also added some crazy sample with a custom Nib, it's not a real life example though.
https://github.com/BillCarsonFr/DZNEmptyDataSet/commit/21112f533f75104cbd0e57eb5a1f31933e005346
BR.
hi @dzenbot when will you merge it :)?
Any status on this?
I have a custom view defined via a xib file (defined with autolayout constraints), which I'm trying to use:
For now the xib has only an UiView with an UILabel inside vertically and horizontally centered.
Am I doing something wrong?