• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Saving unseen NSView with subviews to NSImage
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Saving unseen NSView with subviews to NSImage


  • Subject: Re: Saving unseen NSView with subviews to NSImage
  • From: "Michael Ash" <email@hidden>
  • Date: Tue, 30 Dec 2008 08:22:14 -0500

On Tue, Dec 30, 2008 at 1:11 AM, John Kestner <email@hidden> wrote:
> So am I right in believing that drawRect: should not need to be explicitly
> called in each subview from within my custom view's drawRect:? In any case,
> see if you can make sense of this...
>
>
> // This is in my controller:
> - (IBAction) saveAllVisualizations: (id)sender
> {
>        NSRect pRect = NSMakeRect(0, 0, 480, 640);
>        PlantView *pView = [[PlantView alloc] initWithFrame: pRect];
>        NSManagedObjectContext *context = [[NSApp delegate]
> managedObjectContext];
>
>        NSFetchRequest *fetchAllPersons = [[NSFetchRequest alloc] init];
>        [fetchAllPersons setEntity: [NSEntityDescription
> entityForName:@"Person" inManagedObjectContext:context]];
>
>        for (PersonMO *p in [context executeFetchRequest:fetchAllPersons
> error:nil])
>        {
>                [pView save:p];
>        }
> }

You make this brand-new view, and never put any subviews into it. It
should be pretty well obvious why no subviews ever show up....

>        [self drawRect:pRect];

Do not do this. It will not work. -drawRect: does not magically draw
all subviews too. Of course you have no subviews so it won't work even
then, but this second piece is going to prevent correct behavior even
after you correct the first piece. Use -dataWithPDFInRect: instead.
You mentioned using this in your first e-mail, and it's the right
thing to do. It *will* capture all subviews as well. It wasn't working
for you, presumably, because you had no subviews to capture.

Mike
_______________________________________________

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

  • Follow-Ups:
    • Re: Saving unseen NSView with subviews to NSImage
      • From: John Kestner <email@hidden>
References: 
 >Saving unseen NSView with subviews to NSImage (From: John Kestner <email@hidden>)
 >Re: Saving unseen NSView with subviews to NSImage (From: John Kestner <email@hidden>)
 >Re: Saving unseen NSView with subviews to NSImage (From: "I. Savant" <email@hidden>)
 >Re: Saving unseen NSView with subviews to NSImage (From: John Kestner <email@hidden>)
 >Re: Saving unseen NSView with subviews to NSImage (From: "I. Savant" <email@hidden>)
 >Re: Saving unseen NSView with subviews to NSImage (From: John Kestner <email@hidden>)

  • Prev by Date: Re: respondsToSelector - #import OR compiler warnings?
  • Next by Date: Re: Tweaking a window size
  • Previous by thread: Re: Saving unseen NSView with subviews to NSImage
  • Next by thread: Re: Saving unseen NSView with subviews to NSImage
  • Index(es):
    • Date
    • Thread