在取消分配时尝试加载视图控制器的视图... UIAlertController [英] Attempting to load the view of a view controller while it is deallocating ... UIAlertController

查看:120
本文介绍了在取消分配时尝试加载视图控制器的视图... UIAlertController的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Xcode 7.0的发布版本构建。没有故事板,只有nib文件。

I am building with the release version of Xcode 7.0. No storyboards, just nib files.

我有一个由app delegate创建的 UINavigationController 并用一个初始化它查看控制器。

I have a single UINavigationController created by the app delegate and initialize it with a view controller.

self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
UIViewController *viewController = [[TGMainViewController alloc] initWithNibName:nil bundle:nil];
self.navigationController = [[UINavigationController alloc] initWithRootViewController:viewController];
self.navigationController.navigationBar.barStyle = UIBarStyleBlack;
self.navigationController.navigationBar.hidden = YES;
self.window.rootViewController = self.navigationController;
[self.window makeKeyAndVisible];

使用以下方式导航到新视图后:

After navigating to a new view using:

TGRoutePreparationViewController *viewController = [[TGRoutePreparationViewController alloc] initWithNibName:nil bundle:nil];
[self.navigationController pushViewController:viewController animated:YES];

然后返回使用:

[self.navigationController popViewControllerAnimated:YES];

我收到以下错误:

Attempting to load the view of a view controller while it is deallocating is not allowed and may result in undefined behavior (<UIAlertController: 0x7b29a600>)

虽然我在应用程序中使用 UIAlertController s,但在收到此错误之前没有使用或实例化。这仅在iOS 9.0下运行时才会发生。在iOS 8.4下运行不会产生错误。在所有情况下,应用程序似乎正常运行,导航似乎正常。

While I do use UIAlertControllers in the app, none are used or instantiated before receiving this error. This only happens when running under iOS 9.0. Running under iOS 8.4 produces no error. In all cases, the app appears to function normally and the navigation appears to be working.

我怀疑错误是误导,但我该如何解决这个问题?

I suspect the error is misleading, but how can I fix this?

Per @Nick,这是使用的dealloc方法:

Per @Nick, here is the dealloc method being used:

- (void)deregisterNotificationHandlers {
    [[NSNotificationCenter defaultCenter] removeObserver:self];
}

- (void)dealloc {
    [self deregisterNotificationHandlers];
}


推荐答案

我终于能够追踪它在第三方库Mapbox GL中的 UIActionSheet 类变量。

I was finally able to track it down to a UIActionSheet class variable inside a third-party library, Mapbox GL.

我打开了一个问题开发团队: https://github.com/mapbox/mapbox-gl-native/issues/2475

I opened an issue with that dev team: https://github.com/mapbox/mapbox-gl-native/issues/2475

@Aaoli提及 UIAlertView 的部分信用(以及投票和赏金)一个类变量。

Partial credit (and an up vote and bounty) to @Aaoli for mentioning having a UIAlertView as a class variable.

这篇关于在取消分配时尝试加载视图控制器的视图... UIAlertController的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆