【问题标题】:UITapGestureRecognizer crashing as a zombie during segueUITapGestureRecognizer 在 segue 期间作为僵尸崩溃
【发布时间】:2013-01-18 17:07:18
【问题描述】:

我遇到了奇怪的崩溃。我有一个 UITableViewController,它通过上下文连接到另一个 tableview 控制器。

单击单元格时,我收到以下消息崩溃:

[UITapGestureRecognizer retain]: message sent to deallocated instance 0x8700af0

所以我运行了僵尸仪器,结果如下:

#   Address Category    Event Type  RefCt   Timestamp   Size    Responsible Library Responsible Caller
0   0xf5f36c0   UITapGestureRecognizer  Malloc  1   00:04.128.790   80  UIKit   UINibDecoderDecodeObjectForValue
1   0xf5f36c0   UITapGestureRecognizer  Retain  2   00:04.128.807   0   UIKit   -[UIRuntimeConnection initWithCoder:]
2   0xf5f36c0   UITapGestureRecognizer  Retain  3   00:04.128.880   0   UIKit   UINibDecoderDecodeObjectForValue
3   0xf5f36c0   UITapGestureRecognizer  Retain  4   00:04.128.959   0   UIKit   -[UIRuntimeConnection initWithCoder:]
4   0xf5f36c0   UITapGestureRecognizer  Retain  5   00:04.129.007   0   UIKit   UINibDecoderDecodeObjectForValue
5   0xf5f36c0   UITapGestureRecognizer  Retain  6   00:04.129.017   0   UIKit   UINibDecoderDecodeObjectForValue
6   0xf5f36c0   UITapGestureRecognizer  Retain  7   00:04.129.079   0   UIKit   -[UINib instantiateWithOwner:options:]
7   0xf5f36c0   UITapGestureRecognizer  Release 6   00:04.129.111   0   UIKit   -[UINibDecoder finishDecoding]
8   0xf5f36c0   UITapGestureRecognizer  Release 5   00:04.129.124   0   UIKit   -[UINibDecoder finishDecoding]
9   0xf5f36c0   UITapGestureRecognizer  Release 4   00:04.129.130   0   UIKit   -[UINibDecoder finishDecoding]
10  0xf5f36c0   UITapGestureRecognizer  Release 3   00:04.129.135   0   UIKit   -[UINibDecoder finishDecoding]
11  0xf5f36c0   UITapGestureRecognizer  Release 2   00:04.129.139   0   UIKit   -[UIRuntimeConnection dealloc]
12  0xf5f36c0   UITapGestureRecognizer  Release 1   00:04.129.144   0   UIKit   -[UIRuntimeConnection dealloc]
13  0xf5f36c0   UITapGestureRecognizer  Release 0   00:04.130.131   0   Foundation  __NSFireDelayedPerform
14  0xf5f36c0   UITapGestureRecognizer  Zombie  -1  00:04.131.132   0   UIKit   -[UINib instantiateWithOwner:options:]

tapGestureRecognizer 是通过 IB 添加的,声明为weak。有人建议不要在 ViewDidUnload 中将其设置为 nil,所以我将其注释掉。

现在,如果我转到选项卡控制器中的另一个选项卡并在那里执行一些 segues 并返回到第一个遇到崩溃的表视图控制器,则不会发生崩溃,一切都完美衔接。

同样在崩溃的控制器中,我显示了两种不同类型的对象,有些只是文本,有些是图像。只有图像崩溃。文本单元格很好。

我在 iOS5 和 iOS5.1 上运行它。发生在手机和模拟器上。这不会在 iOS6 设备或 iOS6.1 模拟器上崩溃。

有人知道这里发生了什么吗?

【问题讨论】:

  • 发生这种情况是因为您保留了手势识别器,因为它的父级需要被释放。您可能已经以创建保留周期的方式设置了UITapGestureRecognizer。贴一些示例代码,我看一下。

标签: xcode ios5 segue uitapgesturerecognizer nszombie


【解决方案1】:

我遇到了同样的问题。我有一个静态表格视图,用于我的菜单,该视图与其他视图相结合。只有我有手势识别器的视图在 iOS 5 中不起作用,但在 iOS 6 中可以正常工作。最初我只有 IBOutlets 用于操作,而不是实际的手势识别器本身。我为识别器本身添加了 IBOutlets,现在我没有得到任何僵尸:)

-Rojuinex

【讨论】:

  • 嗯,我以为我有手势识别器,但我可能会再看一遍,最后我把它们拿出来了
【解决方案2】:

到目前为止,解决方案是从我正在使用的控制器中删除手势识别器,这似乎导致了问题。

【讨论】:

    【解决方案3】:

    删除在 Xib 或情节提要中实现的 UITapGestureRecognizer 并使用代码实现它。它工作正常所有操作系统版本。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-01-28
      • 1970-01-01
      • 2012-10-10
      相关资源
      最近更新 更多