首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >UIAlertController泄漏

UIAlertController泄漏
EN

Stack Overflow用户
提问于 2014-10-09 15:58:04
回答 1查看 3.6K关注 0票数 19

我通过以下方法在UIViewController上创建了一个类别,从而在我的应用程序中添加了UIAlertController

代码语言:javascript
复制
- (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:调用的

代码语言:javascript
复制
[self showAlertViewWithTitle:nil message:@"Test message" actions:nil];

你知道为什么我会有这么多的泄密吗?

-编辑--

我在一个示例项目中尝试了以下操作:

代码语言:javascript
复制
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"title" message:@"message"
                                                   delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alertView show];

我也得到了同样的泄密。我真的不知道发生了什么..。

EN

回答 1

Stack Overflow用户

发布于 2015-03-13 16:33:56

这个漏洞似乎在iOS 8.2和Xcode6.2中得到了修复

票数 -2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/26273175

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档