Here's my code, simplified (and tested in this simple form) in order to
demonstrate a mystery:

- (void) illuminate: (NSArray*) arr {
    UIView* v = [[UIView alloc] initWithFrame:self.view.bounds];
    NSLog(@"%@", v);
    CALayer* lay = [v layer];
    v.tag = 111;
    [self.view addSubview:v];
    lay.delegate = self; // <-- ***
    [v release];
    [self performSelector:@selector(unilluminate:)
          withObject:nil afterDelay:0.2];
    return;
}

- (void) unilluminate: (id) dummy {
    for (UIView* aview in [self.view subviews])
        NSLog(@"%i %@", aview.tag, aview);
}

The mystery is what we learn in unilluminate from logging:

(1) the UIView "v" is *not* among the subviews of self.view;

(2) but it *is* among the subviews of self.view if we comment out the
starred line (lay.delegate = self).

How can this be? How can merely setting the layer's delegate make such a
weird change? It appears that setting a layer's delegate somehow messes up
the way the subview hierarchy works.

Oh, I forgot to mention, even weirder: when lay.delegate = self and I
implement drawing in the layer's context as the delegate, the drawing *does*
appear in the right place in the window, even though the view whose drawing
I can see right there in the window is not a subview of the thing I told it
to be a subview of. - m.

-- 
matt neuburg, phd = m...@tidbits.com, http://www.tidbits.com/matt/
pantes anthropoi tou eidenai oregontai phusei
Among the 2007 MacTech Top 25, http://tinyurl.com/2rh4pf
AppleScript: the Definitive Guide, 2nd edition
http://www.tidbits.com/matt/default.html#applescriptthings
Take Control of Exploring & Customizing Snow Leopard
http://tinyurl.com/kufyy8
RubyFrontier! http://www.apeth.com/RubyFrontierDocs/default.html
TidBITS, Mac news and reviews since 1990, http://www.tidbits.com



_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to