I’ve the code as below:
+(void) addHeader:(UIViewController*) hostViewController requiresBackBtn:(BOOL)BooleanValue
{
ApplicationHeader *appHeader = [[ApplicationHeader alloc] initWithNibName:@"ApplicationHeader" bundle:nil];
appHeader.hostViewController = hostViewController;
[appHeader.view setFrame:CGRectZero];
[hostViewController.view addSubview:appHeader.view];
if (BooleanValue) {
[appHeader.view setFrame:CGRectMake(0, 0, 320, 97)];
}
else {
[appHeader.backBtn setHidden:TRUE];
[appHeader.view setFrame:CGRectMake(0, 0, 320, 74)];
}
// [appHeader release]; // This call tends to app Crash!!!!!
}
If I call release to appHeader then the app crashes I press the button which found in appHeader!!
And if I doesn’t this is a memory leak.
What to do now?
🙁
I don’t know what an ApplicationHeader is, but I know that yours has a retained view from
[hostViewController.view addSubview:appHeader.view];Would ApplicationHeader be better as a subclass of
UIView? Without more information, I’m not sure what to suggest as a solution but I think you need to rethink what you are trying to accomplish.