Is kCAOnOrderOut too good to be true?

  • Hi all,

    I've been reading the docs for Core Animation, specifically about
    layer-actions, and it mentions a constant called kCAOnOrderOut which is
    supposedly called when your layer is removed from its superlayer (or
    hidden). However, if it's removed from superlayer, the animation returned
    for the kCAOnOrderOut event is apparently ignored, because the layer is
    removed immediately, instead of when the animation finishes. The docs
    practically declare that this is meant for animations. So, what gives? Is
    this too good to be true? Do I need to use the workaround of adding the
    animation, and in the didStop delegate, removing the layer myself? Code
    would be so much cleaner if just calling -removeFromSuperlayer would invoke
    the animation for me and then remove it itself...

    -Steven
  • On Sat, Mar 6, 2010 at 3:08 PM, Steven Degutis <steven.degutis...> wrote:
    > I've been reading the docs for Core Animation, specifically about
    > layer-actions, and it mentions a constant called kCAOnOrderOut which is
    > supposedly called when your layer is removed from its superlayer (or
    > hidden). However, if it's removed from superlayer, the animation returned
    > for the kCAOnOrderOut event is apparently ignored, because the layer is
    > removed immediately, instead of when the animation finishes. The docs
    > practically declare that this is meant for animations. So, what gives? Is
    > this too good to be true? Do I need to use the workaround of adding the
    > animation, and in the didStop delegate, removing the layer myself? Code
    > would be so much cleaner if just calling -removeFromSuperlayer would invoke
    > the animation for me and then remove it itself...

    Isn't this an artifact of dealing with the model layer? I would expect
    that as far as my code is concerned, the sublayer is removed from its
    parent layer immediately, because I'm only dealing with the model
    layer tree, not the presentation layer tree.

    --Kyle Sluder
  • This seems to suggest that the presentation layer has something to do with
    solving this issue, if it can be solved at all (and I'm hopeful that it can;
    I doubt Apple would have created kCAOnOrderOut solely to be broken from the
    start, and never fix it).

    But from everyone I've talked to, no one has a clue how to make the
    animation given for the kCAOnOrderOut key actually animate visibly on
    screen, either before the layer has been removed from its superlayer, or
    afterwards, once -removeFromSuperlayer has been called.

    If anyone can provide a solution to actually showing the animation returned
    given kCAOnOrderOut, it would be appreciated.

    -Steven

    On Sat, Mar 6, 2010 at 7:18 PM, Kyle Sluder <kyle.sluder...> wrote:

    > On Sat, Mar 6, 2010 at 3:08 PM, Steven Degutis <steven.degutis...>
    > wrote:
    >> I've been reading the docs for Core Animation, specifically about
    >> layer-actions, and it mentions a constant called kCAOnOrderOut which is
    >> supposedly called when your layer is removed from its superlayer (or
    >> hidden). However, if it's removed from superlayer, the animation returned
    >> for the kCAOnOrderOut event is apparently ignored, because the layer is
    >> removed immediately, instead of when the animation finishes. The docs
    >> practically declare that this is meant for animations. So, what gives? Is
    >> this too good to be true? Do I need to use the workaround of adding the
    >> animation, and in the didStop delegate, removing the layer myself? Code
    >> would be so much cleaner if just calling -removeFromSuperlayer would
    > invoke
    >> the animation for me and then remove it itself...
    >
    > Isn't this an artifact of dealing with the model layer? I would expect
    > that as far as my code is concerned, the sublayer is removed from its
    > parent layer immediately, because I'm only dealing with the model
    > layer tree, not the presentation layer tree.
    >
    > --Kyle Sluder
    >

    --
    Steven Degutis
    http://www.thoughtfultree.com/
    http://www.degutis.org/
  • Not yet; still asking everyone I know and hoping a Core Animation wizard
    comes across this thread.

    -Steven

    On Tue, Mar 9, 2010 at 2:49 PM, Jon Buffington <lists...>wrote:

    > Steven,
    >
    > Did you ever find a solution to the kCAOnOrderOut animation problem? I was
    > frustrated by this problem in the past but gave up as the animation was
    > optional.
    >
    > Regards,
    > Jon
    >
    > On Mar 6, 2010, at 11:01 PM, Steven Degutis wrote:
    >
    >> This seems to suggest that the presentation layer has something to do
    > with
    >> solving this issue, if it can be solved at all (and I'm hopeful that it
    > can;
    >> I doubt Apple would have created kCAOnOrderOut solely to be broken from
    > the
    >> start, and never fix it).
    >>
    >> But from everyone I've talked to, no one has a clue how to make the
    >> animation given for the kCAOnOrderOut key actually animate visibly on
    >> screen, either before the layer has been removed from its superlayer, or
    >> afterwards, once -removeFromSuperlayer has been called.
    >>
    >> If anyone can provide a solution to actually showing the animation
    > returned
    >> given kCAOnOrderOut, it would be appreciated.
    >>
    >> -Steven
    >>
    >> On Sat, Mar 6, 2010 at 7:18 PM, Kyle Sluder <kyle.sluder...>
    > wrote:
    >>
    >>> On Sat, Mar 6, 2010 at 3:08 PM, Steven Degutis <
    > <steven.degutis...>
    >>> wrote:
    >>>> I've been reading the docs for Core Animation, specifically about
    >>>> layer-actions, and it mentions a constant called kCAOnOrderOut which is
    >>>> supposedly called when your layer is removed from its superlayer (or
    >>>> hidden). However, if it's removed from superlayer, the animation
    > returned
    >>>> for the kCAOnOrderOut event is apparently ignored, because the layer is
    >>>> removed immediately, instead of when the animation finishes. The docs
    >>>> practically declare that this is meant for animations. So, what gives?
    > Is
    >>>> this too good to be true? Do I need to use the workaround of adding the
    >>>> animation, and in the didStop delegate, removing the layer myself? Code
    >>>> would be so much cleaner if just calling -removeFromSuperlayer would
    >>> invoke
    >>>> the animation for me and then remove it itself...
    >>>
    >>> Isn't this an artifact of dealing with the model layer? I would expect
    >>> that as far as my code is concerned, the sublayer is removed from its
    >>> parent layer immediately, because I'm only dealing with the model
    >>> layer tree, not the presentation layer tree.
    >>>
    >>> --Kyle Sluder
    >>>
    >>
    >>
    >>
    >> --
    >> Steven Degutis
    >> http://www.thoughtfultree.com/
    >> http://www.degutis.org/
    >
    >

    --
    Steven Degutis
    http://www.thoughtfultree.com/
    http://www.degutis.org/
  • Unfortunately the answer is that this is a bug without a clear solution (in the removal case). Your best bet is to hide the layer, then remove it after the animation has completed rather than to remove it directly.

    On Mar 9, 2010, at 11:52 AM, Steven Degutis wrote:

    > Not yet; still asking everyone I know and hoping a Core Animation wizard
    > comes across this thread.
    >
    > On Tue, Mar 9, 2010 at 2:49 PM, Jon Buffington <lists...>wrote:
    >
    >> Steven,
    >>
    >> Did you ever find a solution to the kCAOnOrderOut animation problem? I was
    >> frustrated by this problem in the past but gave up as the animation was
    >> optional.

    --
    David Duncan
    Apple DTS Animation and Printing
previous month march 2010 next month
MTWTFSS
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30 31        
Go to today