【发布时间】:2014-09-27 09:25:00
【问题描述】:
在模拟器中模拟内存警告时出现错误,我的应用程序崩溃:
[UINavigationController 保留]:发送到已释放实例的消息
我正在使用 ARC。
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
UIWindow *window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
_window = window;
[self startWithFlash];
return YES;
}
- (void)startWithFlash
{
[self.window.subviews makeObjectsPerformSelector:@selector(removeFromSuperview)];
__weak typeof (self) weakSelf = self;
WPRSplashViewController *splashViewController = [[WPRSplashViewController alloc] initWithNibName:@"WPRSplashView" bundle:nil doneCallback:^{
[weakSelf startApplication];
}];
self.window.rootViewController = [[UINavigationController alloc] initWithRootViewController:splashViewController];
[self.window makeKeyAndVisible];
}
- (void)startApplication
{
WPRMainViewController *mainViewController = [[WPRMainViewController alloc] init];
UINavigationController * controller = [[UINavigationController alloc] initWithRootViewController:mainViewController];
self.menuController = [[PHMenuViewController alloc] initWithRootViewController:controller
atIndexPath:[NSIndexPath indexPathForRow:0 inSection:0]];
self.window.rootViewController = self.menuController;
[self.window makeKeyAndVisible];
}
这发生在我调用的应用程序的某处:
[((WPRAppDelegate*) [UIApplication sharedApplication].delegate) startWithFlash];
在模拟内存警告之后。
在启用 NSZombie 的情况下运行配置文件工具我得到以下跟踪:
这不是唯一发生此类崩溃的地方。在我使用 UINavigationController 作为视图控制器的包装器并将其呈现为模态视图的每个地方,在模拟内存警告后,我都会遇到此崩溃。
我在其他地方遇到了非常相似的问题,我在这里发布了另一个问题,但没有找到合理的解决方案:Similar issue
【问题讨论】:
标签: ios objective-c automatic-ref-counting