【发布时间】: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