• 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
Adding/removing rectangles from an NSImageView
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Adding/removing rectangles from an NSImageView


  • Subject: Adding/removing rectangles from an NSImageView
  • From: Rob In der Maur <email@hidden>
  • Date: Wed, 11 Feb 2004 21:55:26 +0100

Hi all,

I've searched the archives and found a lot of references to addSubView and removeFromSuperView but nothing seems to solve my problem

I have a dialog in which I can press a button that will show a sheet displaying an NSImageView amongst others. Based on the selection made in the dialog I have to add rectangles to the NSImageView in the sheet.
So, in my -raisePageViewSheet action (the one that shows the sheet), I create a couple of RectangleViews and put them on the NSImageView.
When closing the sheet I clean up the rectangles such that when the sheet has to reappear with different rectangles, none of the old rectangles is showing anymore. To do that, I look for the number of subviews, go through them and call removeFromSuperView for each of them.

The problem is that when the sheet reappears, the old rectangles still show up. I simply can't get rid of them....

Relevant code from the -raisePageViewSheet:

for (i = 0; i < numberOfCaptions; i++) {
APECaption *caption = [[pageStyle captions] objectAtIndex:i];
NSLog(@"Dimension of caption %d is %@...", i, [caption data]);
RectangleView *rectView = [[RectangleView alloc] initWithStringData:[caption data]];
[pageViewImageView addSubview:rectView];
[rectView release]; // should release as adding to the subview did a retain?
}


Relevant code from the -endPageViewSheet:

for (i = 0; i < [[pageViewImageView subviews] count]; i++) {
RectangleView *rectView = [[pageViewImageView subviews] objectAtIndex:i];
[rectView removeFromSuperviewWithoutNeedingDisplay];
// tried [rectView removeFromSuperView] without effect
[pageViewImageView setNeedsDisplayInRect:[rectView bounds]];
}


Note: initWithStringData is a initialization routine in my NSView subclass named RectangleView, which creates a rectangle based on string data.

Anyone can tell me what I'm doing wrong?

cheers,
- Rob In der Maur
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

  • Follow-Ups:
    • Re: Adding/removing rectangles from an NSImageView
      • From: James Chen <email@hidden>
  • Prev by Date: Re: Leak in URL loading system (ctnd.)
  • Next by Date: Re: Pascal String Woes ...
  • Previous by thread: Re: Method declaration conflict with NSURLConnection.
  • Next by thread: Re: Adding/removing rectangles from an NSImageView
  • Index(es):
    • Date
    • Thread