i have a splash page that is displayed on app startup that my client wants me to keep visible for x amount of time. Everything is working great except the image is never released?
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
NSString *fileLocation = [[NSBundle mainBundle] pathForResource:@"splash_page" ofType:@"png"];
NSData *imageData = [[NSData alloc] initWithContentsOfFile:fileLocation];
UIImage *launchImage = [[UIImage alloc] initWithData:imageData];
[imageData release], imageData = nil;
UIImageView *launchImageView = [[UIImageView alloc] initWithImage:launchImage];
launchImageView.frame = CGRectMake(0,
0,
[[UIScreen mainScreen] bounds].size.width ,
[[UIScreen mainS开发者_开发百科creen] bounds].size.height);
launchImageView.tag = 121;
[launchImage release], launchImage = nil;
[self.window addSubview:launchImageView];
[launchImageView release], launchImage = nil;
[self.window makeKeyAndVisible];
[self performSelector:@selector(initApp) withObject:nil afterDelay:kInitDelay];
return YES;
}
- (void)initApp
{
[[UIApplication sharedApplication] setStatusBarHidden:NO];
UIImageView *launchImageView = (UIImageView*)[self.window viewWithTag:121];
[launchImageView removeFromSuperview];
RootNavController *navController = [[RootNavController alloc] initRootController];
self.rootNavController = navController;
[self.window addSubview:navController.view];
[navController release], navController = nil;
}
It is my understanding that removeFromSuperview calls release on the view so this should be released however i can still see a Malloc of 524kb in Intruments Object Allocation tool which im sure is the image. Responsible Library = libRIP.A.dylib and the Responsible Caller ripl_Create.
If i comment out the splash page code and launch the NavController directly i dont have that 524kb.
Any ideas?
Why don't you use the Default.png as your splash screen? Renaming your "Splash_page.png" to "Default.png" will automatically show the splash page on load and then just add UIImageView (with Default.png) to the MainWindow and after x time launch your rootViewController.
精彩评论