Why do all my Interface Builder views wait until one of them is done before loading?
My IB has a number of subviews. One of these is a custom view with a custom 开发者_如何学PythondrawRect method. What I do not understand is why all the views in my IB will not display until that one custom view is done drawing. I'd ideally like to have the other views up on the screen while the custom view is still doing its thing. Is there an easy way to do this?
The custom view is is at the bottom of the hierarchy and the other subviews appear on top of it.
Drawing generally proceeds back-to-front because what a view draws might need to be composited with what is drawn behind it. An exception might be made for opaque views (those that respond to -isOpaque
with YES
), which by definition do not depend on the content drawn behind them.
If drawing is taking a considerable amount of time, you should consider drawing to a buffer outside the main thread and then updating the content of the view with that pre-composited image. You would then replace your custom view with a wrapper around a UIImageView
, which takes as long as it takes to draw to an image and then updates the image displayed by the image view. (This is basically manual double-buffering.)
精彩评论