• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
who stole my UIView?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

who stole my UIView?


  • Subject: who stole my UIView?
  • From: Matt Neuburg <email@hidden>
  • Date: Thu, 12 Aug 2010 16:28:48 -0700
  • Thread-topic: who stole my UIView?

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 = email@hidden, 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 (email@hidden)

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:

This email sent to email@hidden

  • Follow-Ups:
    • Re: who stole my UIView?
      • From: glenn andreas <email@hidden>
    • Re: who stole my UIView?
      • From: Luke the Hiesterman <email@hidden>
  • Prev by Date: Re: term.h not found for iPhone SDK
  • Next by Date: Re: who stole my UIView?
  • Previous by thread: Re: term.h not found for iPhone SDK
  • Next by thread: Re: who stole my UIView?
  • Index(es):
    • Date
    • Thread