Saturday, November 28, 2009

iPhone dev Stupidity 105: Confuse alpha = 0.0 with remove

To avoid flicker when removing a view, you might use an UIView animation to set a alpha = 0.0 and remove the view in the animation stop callback.

Make sure to assert(view.retainCount == 1) before removing. For if you have reference count error (retainCount > 1) and the view will not get removed - but you can't see it since the alpha has set to 0.0.

Of course, you can set the alpa = 0.5 in debug mode to "see" if it's removed finally.

No comments: