如果我将手势识别器添加到名为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:
,或者在不再使用单元格时是否删除并释放手势识别器?
答案 0 :(得分:44)
手势识别器被添加到视图的内部NSMutableArray中。取消分配视图后,将释放此数组。因此,-removeGestureRecognizer:
不需要手动调用。