I have a UIViewController that contains a UIView. Between every time the viewcontroller is displyaed, the UIView has to be cleared and the content reloaded. The problem is that the old content still appears in the UIView.
Load data before controller becomes visible:
- (void)viewWillAppear:(BOOL)animated
{
contentView = [[ContentView alloc] initWithFrame:CGRectMake(10, 10, 100, 100)];
contentView.userInteractionEnabled = NO;
[self.view addSubview:contentView];
if([self loadContentData] == NO) {
[contentView release];
return NO;
}
return YES;
}
Remove content after controller is hidden:
- (void)viewDidDisappear:(BOOL)animated
{
[contentView removeFromSuperview];
[contentView release];
}
Why is this cleanup not sufficient?