On Jan 13, 2010, at 11:24 AM, Matt Neuburg wrote: > On Tue, 12 Jan 2010 14:18:05 -0600, Michael Gardner <gardne...@gmail.com> > 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 (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