Re: who stole my UIView?
Re: who stole my UIView?
- Subject: Re: who stole my UIView?
- From: David Duncan <email@hidden>
- Date: Fri, 13 Aug 2010 09:53:19 -0700
On Aug 12, 2010, at 5:53 PM, Matt Neuburg wrote:
> Where are the warnings?
-[UIView layer] has this to say: "Warning: Since the view is the layer’s delegate, you should never set the view as a delegate of another CALayer object. Additionally, you should never change the delegate of this layer."
> We're working with CALayer so that's where they need to be. Here's what we find under CALayer's delegate property:
I'm actually kind of surprised that the documentation mentions this at all. That said, the warning is ambiguous and I've filed a bug asking for the comment to be made more explicit.
In general however, it is advisable to treat objects that are created on your behalf as at least somewhat special, in that you don't know the full extent of the dependencies that the creator setup on that object. You weren't just working with a CALayer here, you were also working with a UIView and you need to be mindful of its requirements as well.
> All I was trying to do was save a little memory by not bothering to create a bitmap and draw into it; I was just looking for a way to draw directly into a layer's context (without subclassing). This seems like an innocent enough thing to want to do...
This can be accomplished directly using UIImageView and UIGraphicsBeginImageContext(). The data is marked copy-on-write, so you won't be using additional memory, provided that you are on iOS 3.2 or later (there was a bug in 3.1 and prior where UIGraphicsBeginImageContext() used a format that caused Core Animation to make a copy of the data).
--
David Duncan
_______________________________________________
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