I have a view that has rows and columns of imageviews in it.
If this view is resized, I need to rearrange the imageviews positions.
This view is a subview of another view that gets resized.
Is there a way to detect when this view is being resized?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
As Uli commented below, the proper way to do it is override
layoutSubviewsand layout the imageViews there.If, for some reason, you can’t subclass and override
layoutSubviews, observingboundsshould work, even when being kind of dirty. Even worse, there is a risk with observing – Apple does not guarantee KVO works on UIKit classes. Read the discussion with Apple engineer here: When does an associated object get released?original answer:
You can use key-value observing:
and implement: