UIAlertController泄漏 [英] Leaks with UIAlertController
问题描述
我在我的应用中添加了 UIAlertController
,方法是使用以下方法在 UIViewController
上创建一个类别:
I added UIAlertController
in my app by creating a category on UIViewController
with the following method:
- (void)showAlertViewWithTitle:(NSString *)title
message:(NSString *)message
actions:(NSArray *)alertActions
{
UIAlertController *alertController = [UIAlertController alertControllerWithTitle:title ? : @"" message:message preferredStyle:UIAlertControllerStyleAlert];
if (alertActions.count) {
for (UIAlertAction *action in alertActions) {
[alertController addAction:action];
}
} else {
UIAlertAction *action = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:nil];
[alertController addAction:action];
}
[self presentViewController:alertController animated:YES completion:nil];
}
首先,一切看起来都不错但是当我用仪器分析泄漏时,每次我称之为这种方法,会出现一些泄漏:
At first, everything looks great but when I analyze leaks with Instruments, each time I call this method, some leaks appear:
以下是 showAlertViewWithTitle:message:actions:
的调用是如何完成的
Here is how the call of showAlertViewWithTitle:message:actions:
is done
[self showAlertViewWithTitle:nil message:@"Test message" actions:nil];
我知道为什么会收到所有这些泄漏?
Any idea why I get all these leaks?
- 编辑 -
我在示例项目中尝试了以下内容:
I tried the following in a sample project:
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"title" message:@"message"
delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alertView show];
我得到同样的泄密。我真的不确定发生了什么...
and I get the same leaks. I'm really not sure what's going on...
推荐答案
这是一个iOS错误。
这也是SO问题的重复 UTAlertController或UIActionSheet的iOS 8仅内存泄漏提前1天发布。
This is also a duplicate of SO question iOS 8 Only Memory Leak with UIAlertController or UIActionSheet posted 1 day earlier.
参见 Apple Bug Reporter 问题 21005708 ,ARC下的UIAlertController内存泄漏。
See Apple Bug Reporter issue 21005708, Memory leak in UIAlertController under ARC.
这篇关于UIAlertController泄漏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!