我通过以下方法在UIViewController
上创建了一个类别,从而在我的应用程序中添加了UIAlertController
:
- (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];
}
起初,一切看起来都很好,但当我使用Instruments分析泄漏时,每次调用此方法时,都会出现一些泄漏:
下面是如何完成showAlertViewWithTitle:message:actions:
调用的
[self showAlertViewWithTitle:nil message:@"Test message" actions:nil];
你知道为什么我会有这么多的泄密吗?
-编辑--
我在一个示例项目中尝试了以下操作:
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"title" message:@"message"
delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alertView show];
我也得到了同样的泄密。我真的不知道发生了什么..。
发布于 2015-03-13 16:33:56
这个漏洞似乎在iOS 8.2和Xcode6.2中得到了修复
https://stackoverflow.com/questions/26273175
复制相似问题