Reputation: 6109
I am going through a tutorial that mentions the following method:
-(void)layoutSubviews
located in CustomerCell.m
When is this method called during the app execution? Is it automatically invoked? I dont see any callback.
Upvotes: 7
Views: 10220
Reputation: 2201
You will find your answer here
EDIT: copied directly from the blog:
Upvotes: 13
Reputation: 45598
The layoutSubviews
method will be called any time the system thinks your view needs to be layed out again. For example, if the view's frame is changed, or a subview is added, etc. If you need to manually trigger this, you can call the setNeedsLayout
method.
Upvotes: 1
Reputation: 1365
You are correct. Layout subviews is automatically invoked. Check the docs for more information on it.
The docs don't specifically say WHEN this is called. However, you can pretty much guarantee it is called rather often. You really only want to override this method when you can't have your subviews resize or move themselves using struts and springs. One instance would be reorganizing subviews positions when the device changes orientation.
Upvotes: 1