Try this:
UIView *v = [self.containerView viewWithTag:[n integerValue]];
v.hidden = YES;
[self.containerView bringSubviewToFront:v];
[v removeFromSuperview];
Another thing I just noticed from the UIView class document - see the last sentence:
removeFromSuperview
Unlinks the receiver from its superview and its window, and removes it from the responder chain.
- (void)removeFromSuperview
Discussion
If the receiver’s superview is not nil, this method releases the receiver. If you plan to reuse the view, be sure to retain it before calling this method and be sure to release it as appropriate when you are done with it or after adding it to another view hierarchy.
Never invoke this method while displaying.
UPDATE: It is now 2014 and removing a subview without hiding it works perfectly fine. The original poster's code should work as-is:
UIView *v = [self.containerView viewWithTag:[n integerValue]];
[v removeFromSuperview];
This will remove v and any views it has attached to it as subviews, leaving behind containerView and any siblings of v.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…