• 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: Releasing a sub-view
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Releasing a sub-view


  • Subject: Re: Releasing a sub-view
  • From: Lorenzo <email@hidden>
  • Date: Wed, 28 Apr 2004 18:02:27 +0200

Hi,
thanks for your reply. I did what you say but it didn't work.
I did:

- (void)startAnimation
{
theView = [[XAView alloc] initWithFrame:theFrame];
[self addSubview:theView];
[theView release];
}

- (void)stopAnimation
{
[super stopAnimation];
[theView removeFromSuperviewWithoutNeedingDisplay];
[theView release];
}

theView has been released
but I still see the white flash...

I also tried to define a dealloc method in the ScreenSaverView class
just to try to release here theView, but it has never been invoked

- (void)dealloc
{
NSLog(@"ScreenSaverView dealloc");
// never seen this log
}

Any idea to avoid the flash?

Best Regards
--
Lorenzo
email: email@hidden

> From: Jeremy Dronfield <email@hidden>
> Date: Wed, 28 Apr 2004 13:50:46 +0100
> To: Lorenzo <email@hidden>
> Cc: Cocoa Dev <email@hidden>
> Subject: Re: Releasing a sub-view
>
> On 28 Apr 2004, at 1:45 pm, Jeremy Dronfield wrote:
>
>> You should release theView once you have added it to its superview,
>> thus:
>>
>> [ssView addSubview:theView];
>> [theView release];
>>
>> Then, if you want to reuse it, you should retain it before removing it:
>>
>> [theView retain];
>> [theView removeFromSuperviewWithoutNeedingDisplay];
>
> I ought to add here that if you *don't* want to reuse theView, don't
> retain it. Once it's removed from its superview, it will be released
> and your retain count goes to 0.
>
>>
>> As for the "white flash", this is presumably your window redrawing
>> without theView. The documentation for NSView states that
>> -removeFromSuperview should never be invoked during display. Use
>> -removeFromSuperviewWithoutNeedingDisplay instead.
>>
>> Hope this helps
>>
>> Regards,
>> -Jeremy
>>
>> On 28 Apr 2004, at 1:07 pm, Lorenzo wrote:
>>
>>> Hi,
>>> I create a custom NSView
>>> theView = [[XAView alloc] initWithFrame:theFrame];
>>> now theView has retainCount = 1;
>>> then I add it to a ScreenSaverView
>>> [ssView addSubview:theView];
>>> now theView has retainCount = 2;
>>>
>>> when the ScreenSaverView calls
>>> - (void)stopAnimation
>>> {
>>> [theView release];
>>> [super stopAnimation];
>>> }
>>>
>>> theView has not been released because it has still retainCount = 1.
>>> Anyway I see a good fade-out of the screen-saver. Instead if I call
>>> - (void)stopAnimation
>>> {
>>> [theView removeFromSuperview];
>>> [theView release];
>>> [super stopAnimation];
>>> }
>>>
>>> theView has been released properly.
>>> The problem is that when theView has been removed from the superview
>>> I see a white flash on the screen. Then I see the fade-out.
>>> How to avoid this annoying white flash?
>>>
>>>
>>> Best Regards
>>> --
>>> Lorenzo
>>> email: email@hidden
>>> _______________________________________________
>>> 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.
_______________________________________________
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: Releasing a sub-view
      • From: Jeremy Dronfield <email@hidden>
    • Re: Releasing a sub-view
      • From: Allan Odgaard <email@hidden>
References: 
 >Re: Releasing a sub-view (From: Jeremy Dronfield <email@hidden>)

  • Prev by Date: can't get NSZombie to work
  • Next by Date: clearing up framework dependancies
  • Previous by thread: Re: Releasing a sub-view
  • Next by thread: Re: Releasing a sub-view
  • Index(es):
    • Date
    • Thread