iphone/ipad adding adding and removing a subview doesnt work

Posted by Mark on Stack Overflow See other posts from Stack Overflow or by Mark
Published on 2010-05-18T03:54:31Z Indexed on 2010/05/18 4:00 UTC
Read the original article Hit count: 331

Filed under:
|
|

Im have a slight amount of trouble adding a new view to my scene, I have the code like this:

- (void) showMyDayView {
NSLog(@"My Day View was touched");

MyDayViewController *temp = [[MyDayViewController alloc] initWithNibName: @"MyDayView" bundle:nil];
self.myDayViewController = temp;

NSLog(@"superview: %@", [[self mainNavView] superview]);
[[self mainNavView] removeFromSuperview];
NSLog(@"after removal main: %@", [self mainNavView]);
NSLog(@"after removal view: %@", [self view]);
NSLog(@"after removal superview: %@", [[self view] superview]);

[[[self view] superview] addSubview: [self.myDayViewController view]];

[temp release];
}

And when I run this code, the console says "after removal superview: (null)"

so when I add the subView to the superview, nothing happens because the superview is null.

Any ideas?

Thanks Mark

© Stack Overflow or respective owner

Related posts about ipad

Related posts about iphone