Possible Duplicate:
iPhone — the input parameter to UIView's sizeThatFits method
Specifically, what's its argument supposed to be? The documentation says that it's the receiver's current size, but a view can always use self.bounds.size
, so that doesn't make sense.
Is it supposed to be the available space? In other words, is the parent asking the child, "given that there's available space of X x Y points, how big do you want to be?".
I simply believe the doc is wrong when it says "The current size of the receiver". It is only a use case but there are others: for example if you want the view to return its very best size given an arbitrary size you will call this method passing your arbitrary size as the parameter.
Is it supposed to be the available space? In other words, is the parent asking the child, "given that there's available space of X x Y points, how big do you want to be?".
Yes, you've got the idea BUT don't restrict the meaning of the argument to the "available space". It's just an arbitrary size that may or not correspond to an available space. It depends on how you are using the method. However the view is supposed to always return what it considers to be its best size (the size that best fits its subviews) if it has to fit into the size passed as an argument.
Look here, this should answer your question: iPhone -- the input parameter to UIView's sizeThatFits method
Pretty much exactly that. Classes like UIPickerView
and UILabel
have content that works best at particular sizes, and as such they return those specific sizes rather than the more general bounds
size.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With