views:

114

answers:

2
UIView *stateView = [getSomeUIView thisOne];
CGRect currentFrame = stateView.frame;
if(currentFrame.size.height == 0.0) {
    currentFrame.size = CGSizeMake(260, 60);
}
else {
    currentFrame.size = CGSizeMake(260, 0);
}
stateView.frame = currentFrame;

I would expect all the subviews would be hidden when the height of the frame is set to zero however this does not happen (in the iPhone 4.0.1 Simulator). Any suggestions why or alternatives?

I was planing to later animate the frame so it's a sliding effect. I can not use the y position and move it off screen nor can I create a element to hide it behind since I'm working with a background image and everything on top is transparent/alpha layer.

A: 

Subviews will only change size if you set their springs and struts to do so.

By default, they are set to "stay the SAME width and height, and stay the same distance from top left corner of the parent view".

You can set the springs/struts in Interface Builder, or in code. e.g.:

aSubView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
Adam
this won't solve my problem, since the subview - in my case UIButtons - with this options still won't go under their set height. Even if I tweaked them to go under their set height I believe this would be suboptimal, since every subview would be redrawing it self. I just thought of a solution yesterday eve and going to post it here right now.
Thomas
A: 

Use UIScrollView instead of UIView. UIScrollView is made to hide "overflow" and works perfectly.

Thomas