【问题标题】:Instruments makes app crash when setting image property of UIImageViewInstruments 在设置 UIImageView 的图像属性时使应用程序崩溃
【发布时间】:2011-08-21 02:49:44
【问题描述】:

我在使用 Instruments 时遇到了一些问题。我的应用程序运行良好,没有崩溃,但我想使用 Instruments 检查内存泄漏。唯一的问题是,Instruments 使应用程序每次都在同一个地方崩溃——没有 Instruments 永远不会崩溃。

我已经确定了导致应用崩溃的确切线路。当我将其注释掉时,应用程序不会崩溃。

这是给 Instruments 带来麻烦的行:

self.speakerImageView.image = image;

speakerImageView 是这样声明的:

@property (nonatomic, retain) IBOutlet UIImageView *speakerImageView;

image 是一个有效的 UIImage 对象。

有什么想法吗?

【问题讨论】:

  • 在您调用 self.speakerImageView.image = image; 时是一个有效的对象(不是 nil 或释放的对象)吗?
  • 仪器是通过模拟器还是通过设备?
  • 通过模拟器。甚至不会通过设备运行。

标签: objective-c xcode ios ipad instruments


【解决方案1】:

您是否使用图像命名?我要问的是因为使用 imagenamed 会导致崩溃。不要使用命名的图像并再试一次。

【讨论】:

  • 不,我实际上是在使用 imageWithData:
  • 尝试使用 speakerImageView.image = image;而是 self.speakerImageView.image = image;
  • 令人惊讶的是,这成功了!你能给我解释一下吗??
猜你喜欢
  • 1970-01-01
  • 2012-08-15
  • 1970-01-01
  • 1970-01-01
  • 2018-10-01
  • 2015-09-29
  • 2015-07-08
  • 2019-08-22
  • 1970-01-01
相关资源
最近更新 更多