On Jun 19, 2011, at 2:14 PM, Ken Tozier wrote:

> On Jun 19, 2011, at 3:57 PM, Kyle Sluder wrote:
> 
>> You're setting the contents property of the layer. So returning nil
>> from -actionForKey: should do the trick. I just found this post by
>> Matt Neuburg that might explain why you're having trouble:
>> http://www.cocoabuilder.com/archive/cocoa/293161-calayer-instant-content-update.html
>> 
>> Basically, the sentinel value that tells Core Animation to stop
>> looking for an action to apply to a property change is NOT nil, as
>> implied by the documentation and David Duncan's post. Rather, it is
>> NSNull. "nil" means "I don't have an answer for you; consult someone
>> else," which can be the layer _or_ the default set of implicit
>> actions! Rather, try returning [NSNull null] from your -actionForKey:
>> override.
> 
> I read the link and tried both of the following:
> 
> - (id) actionForKey:(NSString *) inKey
> {
>       if ([inKey isEqualToString: @"contents"])
>               return [NSNull null];
>       
>       return [super actionForKey: inKey];
> }
> 
> Produced the error: 
> -[NSNull runActionForKey:object:arguments:]: unrecognized selector sent to 
> instance 0x7fff701d5fa0

Which value is the sentinel depends on context, hence my recommendation to read 
the documentation. Specifically when using the actions dictionary, style 
dictionary or -actionForLayer:forKey: the sentinel is [NSNull null] and 
nil/non-existant means "keep searching". In other contexts nil means "no 
action".

> Thanks again for the reply it cleared some things up. At this point though, 
> it's probably a good time to put CALayers aside, at least for now. The 
> inability to simply set the shape of the layer and turn off the blasted 
> animations, when needed, is a deal breaker for me. Not sure why Apple made it 
> so squirrely, but really, the entire point of my subclass was to make it 
> possible to do something like  the following.


You probably aren't overriding enough properties default animations. As stated, 
@"contents" is literally only the bitmap backing the layer. It does not affect 
any other animation the layer may perform. From the sounds of it, you also have 
a border and the cornerRadius set to a non-zero value. If you want to disable 
those animations too, you need to disable them for those associated keys too.

Or you can use the CATransaction as you originally tried, but you need to do it 
around the values that you are actually changing. @"contents" is a bit special 
because it is typically set outside of your control, but other properties tend 
no to be.
--
David Duncan

_______________________________________________

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