我正在使用Xcode 7.0的发行版进行构建.没有故事板,只有nib文件.

我有一个应用程序委托创建的UINavigationController,并用视图控制器初始化它.

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];

使用以下命令导航到新视图后:

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个,但在收到此错误之前,没有使用或实例化任何一个.只有在iOS 9下才能运行.在iOS 8.4下运行不会产生错误.在所有情况下,应用程序似乎都能正常运行,导航系统似乎也能正常工作.

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

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

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

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

推荐答案

我终于能够在第三方库Mapbox GL中找到UIActionSheet类变量.

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

@Aaoli提到将UIAlertView作为一个类变量,这部分归功于@Aaoli(以及向上投票和奖励).

Swift相关问答推荐

运行异步任务串行运行

如何防止自动状态恢复,如果应用程序被启动打开特定的文档?

SWIFT:使字典数组值可变

如何才能在同一线程上调用类中的每个方法,而不对每个调用使用同步块?

根据其属性组合 2 个模型以在 Swift 中创建另一个模型

为什么我的Swift app不能用xcodebuild构建,但是用XCode可以构建?

用逻辑运算符保护让

用户输入以更改通过点击生成的形状大小

您可以在运行时访问 Picker 元素并更改它们的 colored颜色 吗

SwiftUI 中的计时器崩溃屏幕

如何以快速 Select 器菜单样式调整图像大小

单元测试和私有变量

即使设置为从不也可以访问 iOS11 照片库

使 struct 可散列?

如何在 Swift 中将对象归零

如何从 Swift 中的字符串生成条形码?

更改日期 Select 器的文本 colored颜色

不能从非开放类继承 swift

为 UIImagePicker 设置委托返回错误

WKWebView 确实从本地文档文件夹加载资源