我是否需要发布手势识别器?

时间:2010-07-18 08:06:13

标签: iphone memory-management gesture-recognition uigesturerecognizer

如果我将手势识别器添加到名为cell的表格单元格中,例如:

UILongPressGestureRecognizer *_longPressRecognizer = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(cellGestureRecognized:)];
_longPressRecognizer.allowableMovement = 20;
_longPressRecognizer.minimumPressDuration = 1.0f;
[cell addGestureRecognizer:_longPressRecognizer];
[_longPressRecognizer release], _longPressRecognizer = nil; 

我是否需要在某个时刻在此单元格上手动调用-removeGestureRecognizer:,或者在不再使用单元格时是否删除并释放手势识别器?

1 个答案:

答案 0 :(得分:44)

手势识别器被添加到视图的内部NSMutableArray中。取消分配视图后,将释放此数组。因此,-removeGestureRecognizer:不需要手动调用。