我有一个启动页面,显示在应用启动时,我的客户希望我在x时间内保持可见状态。一切都很好,除了图像永远不会发布?
- (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 mainScreen] 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;
}
我的理解是removeFromSuperview在视图上调用release,所以这应该被释放但是我仍然可以在Intruments Object Allocation工具中看到一个524kb的Malloc,它确实是图像。 Responsible Library = libRIP.A.dylib和Responsible Caller ripl_Create。
如果我注释掉启动页面代码并直接启动NavController我没有那个524kb。
有什么想法吗?
答案 0 :(得分:-1)
为什么不使用Default.png作为启动画面?将“Splash_page.png”重命名为“Default.png”会自动在加载时显示启动页面,然后只需将UIImageView(带Default.png)添加到MainWindow,并在x时间后启动rootViewController。