Hey everyone,
I have a UIView in a UIViewController to which I add a custom subview in the viewDidAppear
method.
MyView *myView = [[MyView alloc] initWithLabelText:text];
[self.view addSubview:myView];
[myView release];
The text
variable is a string used on a label in myView
. This text
changes every time you come back to the current view. But it seems that viewDidAppear
does not reload the view - it rather loads a new view over the old one - so I have two labels over each other.
I tried to use viewWillAppear
but it doesn't make any difference. I also tried to use [self.view setNeedsDisplay]
- doesn't help. I also tried to make myView
an instance variable, but it also didn't help.
What worked was to remove the view explicitly, when I declared it as an instance variable:
- (void)viewDidDisappear:(BOOL)animated
{
[_myView removeFromSuperview];
}
Although there is this workaround I would like to simply reset the view when getting back to it. Does anybody know how to do that? I would appreciate it ;)