Jacksonkr
Jacksonkr

Reputation: 32217

ios autosize for uilabel in subview

layout:

from the container I do:

UIView *someItemContentView = --code for an item goes here--;
[someItemContentView sizeToFit];
[self.item.subItemsContainer addSubView:someItemContentView];
[self.item.subItemsContainer sizeToFit];
[self.item sizeToFit];
[self sizeToFit];

However, the subItem is still clipped to it's frame. Meaning the frame didn't "size to fit". Is this not the correct way to size all my views dynamically?

Upvotes: 0

Views: 487

Answers (1)

sch
sch

Reputation: 27506

sizeToFit calls sizeThatFits to determine the size to be used. But as the documentation says:

The default implementation of this method returns the size portion of the view’s bounds rectangle.

Which basically means that the default implementation does nothing, and it is up to the subclasses to implement the appropriate sizeThatFits behavior.

Upvotes: 1

Related Questions