views:

595

answers:

3

I am apparently in some swirling UIView hell zone at the moment where up is down sibling is parent and my brain is completely fried.

Here's the deal. Really, really simple. I have a container view with N leaf node sibling subviews. No tricks here, dead simple. I do the following:

// occludedPageSet is the set of view tags corresponding to views that are off screen and // thus fully occluded. This was determined geometrically.

for (NSNumber *n in occludedPageSet) {

            // Point to a view corresponding to this tage
 UIView *v = [self.containerView viewWithTag:[n integerValue]];

            // Hide this view
 if (v.hidden == NO) {

                    NSLog(@"View %d is occluded. Hide it.", [n integerValue]);
  v.hidden = YES;

 } // if (v.hidden == NO)


} // for (occludedPageSet)

Pretty tame stuff. Unfortunately ALL sibling views vanish! What the?!? How is this possible?

Do I need a [retain]/[release] for v here. I'm stumped.

Baffled, Doug

+1  A: 

Apparently, all of your views are included in occludedPageSet, or all of your tags are the same n.

NSNumber *n in occludedPageSet

Or, one of the v views is the parent of the rest, so when you hide it, you hide them all.

Jordan
A: 

Make sure self.containerView's tag is something completely different from any of the children's tags. Calling viewWithTag will return the receiver if it is the given tag, which will in turn hide all of your views. Either step through the iteration or print out the address that v points to so that you know you're occluding what you should be occluding.

kidnamedlox
+1  A: 

Am I missing something about the problem here? It's only natural that if you hide a view, any view it holds as a subview would be hidden as well. After all, you can't see the container view...

If you put ten things in a box and make the box invisible, wouldn't you expect that to mean you couldn't see the things in the box? Similarly an invisibility cloak would be of little use if only the cloak were invisible and not the person beneath...

If you need some things visible and some not, work on the specific items and not the container.

Kendall Helmstetter Gelner