The right way to manage subviews in a UIControl

Posted by ed94133 on Stack Overflow See other posts from Stack Overflow or by ed94133
Published on 2010-05-27T02:45:26Z Indexed on 2010/05/27 2:51 UTC
Read the original article Hit count: 428

(iPhone SDK 3.x:) I have a UIControl subclass that creates a different number of subviews depending on the length of an NSArray property. Please take my word for it that this needs to be a UIControl rather than a UIView.

Currently I implement subview management in drawRect, beginning by removing all subviews and then creating the appropriate number based on the property. I don't think this is very good memory management and I'm not sure if drawRect is really the appropriate place to add subviews. Any thoughts on the best way to handle this pattern?

Thank you.

© Stack Overflow or respective owner

Related posts about memory

Related posts about iphone-sdk-3.0