events - iPhone: Resizing in drawRect: -


I have a UIView based control that I need to resize based on the different criteria and properties of the control. I'm not sure that the way I am doing is the best way, but so far I have found that there is only one job. Because the size of the control depends on the different properties, I can not set the size in a constructor

I have a method called setupControl: in which all the code is included to finish setup based on the property set . I do not want setupControl: manually called, so in drawRect I have found that I need to call it and then a queue of a selector like this: [self performanceSelector: @selector (setupControl) withObject: later Self: 1]; Return;

At the bottom of setupControl: I do it again:

  [auto-set display]; Self.hidden = NO;  

I have also overridden these overframes: and these wasticoders: the constructor so that they can set UIView to hide the setup code. This idea is to eliminate any "flash" on the display because the shape of the control varies.

As I said it works fine, the controls can be drawn to the ii size xib file and then You can set yourself to the right size at run time.

My question is whether the selector has to draw this method of drawing: and then using setNeedsDisplay is the only way to do this? O Is there some method I have not found that I can override? or something else?

Do you want to override, instead of drawing, you are changing the layout Custom drawing does not apply Has been doing.

You may have to use custom multiplier for any property that changes the size of the view and call [Self Setdowns Layout] in Setter to ensure that your Layoutsubewews method is called before calculating your visual size.


Comments