Re: Snapshotting hidden UIViews
Re: Snapshotting hidden UIViews
- Subject: Re: Snapshotting hidden UIViews
- From: Michael Gardner <email@hidden>
- Date: Wed, 13 Jan 2010 16:48:02 -0600
On Jan 13, 2010, at 11:24 AM, Matt Neuburg wrote:
> On Tue, 12 Jan 2010 14:18:05 -0600, Michael Gardner <email@hidden>
> said:
>> I'm trying to create a "snapshot" UIImage from a UITextView that's inside a
> larger, hidden UIView. renderInContext: works fine for visible UIView layers,
> but I can't get consistent results for hidden views.
>>
>> I read somewhere (can't recall the source, but it wasn't authoritative) that
> this is expected behavior, and that -renderInContext: is only guaranteed to work
> for visible UIViews' layers. Is this true? If so, how else can I replicate
> *exactly* what my UITextView would look like when visible?
>
> In my JACTVocab app I have a similar problem: I need to make a "snapshot" of
> a situation in my window that doesn't exist yet. In other words, my window
> is in situation A, but I need a snapshot of situation B. I will eventually
> show the user situation B, but I need the snapshot first.
>
> So what I do is: I take a snapshot of situation A, and cover the window with
> a borderless window containing that snapshot. This hides what I am about to
> do in the real window. Now I change the situation in the window to situation
> B. The user cannot see this happening because snapshot of situation A is
> covering the window. Now I take the snapshot of situation B (this works
> perfectly well even though the second window is covering it).
>
> The hand is quicker than the eye, and the user never notices (I hope).
>
> Also, I use cacheDisplayInRect, not renderInContext. But it may be that
> there are reasons why you don't have that option...
>
> Hope this helps some - m.
Thanks for this useful tip, but I hope I don't have to resort to your method. It just feels... dirty, you know?
I'm not using -cacheDisplayInRect: because it doesn't exist in UIView, as far as I know.
I also tried calling -drawRect: on my hidden view (after setting the context with UIGraphicsBeginImageContext()), but it doesn't seem to do anything.
-Michael_______________________________________________
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