Re: Making views disappear and reappear
Re: Making views disappear and reappear
- Subject: Re: Making views disappear and reappear
- From: Mark T <email@hidden>
- Date: Sat, 23 Jun 2001 21:19:34 -0400
You do mean retain it *before* you remove it from the view
hierarchy, don' t you?
This is what I'm doing, and it still fails to reappear after
addSubview. Here's the code for the Hide/Show button's action, maybe
someone can figure out what I'm doing wrong:
- (IBAction)hideOrShow:(id)sender
{int i;
BOOL scrollViewDoesExist = NO;
NSScrollView * theScrollview = [self myScroll];
NSView * theSuperview = [theScrollview superview];
NSRect rectToRedraw = [theScrollview frame];
NSArray * tempArray = [[sender superview] subviews];
for(i = 0; i<[tempArray count] ; i++)
if([tempArray objectAtIndex:i] == [self myScroll]);
scrollViewDoesExist = YES;
if(scrollViewDoesExist)
{ [sender setTitle:@"Show"];
[theScrollview retain];
[theScrollview removeFromSuperview];
[theSuperview setNeedsDisplayInRect:rectToRedraw];
[[self addButton] setEnabled:NO];
[[self removeButton] setEnabled:NO];
} else {
[sender setTitle:@"Hide"];
[theSuperview addSubview:theScrollview];
[theSuperview setNeedsDisplayInRect:rectToRedraw];
[theScrollview release];
[[self addButton] setEnabled:YES];
[[self removeButton] setEnabled:YES]; } }