tags:

views:

33

answers:

1

Hi!

I want to hide a label if the labels text value is empty. I have no trouble checking this but if I use [label setHidden:YES] it still leaves the space.

I'm adding this label in Interface Builder by the way.

I have tried using [label setFrame: CGRectZero], but the label keeps taking up space!

What shall I do?

+1  A: 

Hiding or removing a view does not affect the position of other subviews of the view's parent.

If you have a column of labels, and don't want empty labels to take up space, you will need to adjust the location of the other labels in the column to shift those below the hidden label up.

GregInYEG
Serious... All the labels positions is made in IB. What's your recommendation when that's my case?
Fernando Redondo
You'll still have to adjust their positions programatically if you want their positions to change. The springs and struts in IB control the position of the elements relative to their containing view, but not relative to each other.
GregInYEG
Okey thanks Greg. I'm a ASP.NET-developer who recently made the step towards iphone development. So I thought it would happen automatically.
Fernando Redondo