views:

408

answers:

1

in my viewcontroller's view i need to add a couple of custom UIView's, i do that in the loadView method

so in my custom uiview's drawRect method i add a couple of UILabel's.

in my viewcontroller's view i need to add all those custom UIView's underneath each other but i don't know what their height is

sometimes 20px, 40px, 60px, depending on the outcome of the drawRect

so when i init my custom UIView i give it a frame height of lets say 50.. but when the drawRect is done and it's only 20, 50 is too much so i need to adjust the frame height

but how can i determine what's the visible height of the custom UIView and where can i catch it in my viewcontroller when the custom uiview has finished his drawRect method

is there some kind of autoresize and where do i catch it in my viewcontroller, so i can position the custom uiview right under neath each other.

A: 

Consider using the tag property of UIView as a way to access your dynamically created views after drawRect has executed. At this point you should be able to get the height of the dynamically created views by accessing the frame.size.height of the view. Use this to position them to be stacked on top of each other as you desire.

If you provide code samples of what you're doing I or other people can give you more specific assistance.

Bart

Bart Gottschalk
actually he question would be more like if add in my loadView of my viewcontroller a custom uiview when do i know in my viewcontroller when the custom uiview has executed the drawRect method
Andy Jacobs