Iphone 识别按下my UILongPressGestureRecognitor的单元格,无法向其添加标记
我将UILongPressGestureRecognitor添加到单元格中,如下所示:Iphone 识别按下my UILongPressGestureRecognitor的单元格,无法向其添加标记,iphone,objective-c,ios,xcode,Iphone,Objective C,Ios,Xcode,我将UILongPressGestureRecognitor添加到单元格中,如下所示: UILongPressGestureRecognizer *longpressGesture = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(longPressHandler:)]; longpressGesture.minimumPressDuration = 2.5;
UILongPressGestureRecognizer *longpressGesture = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(longPressHandler:)];
longpressGesture.minimumPressDuration = 2.5;
longpressGesture.t
[longpressGesture setDelegate:self];
[cell addGestureRecognizer:longpressGesture];
[longpressGesture release];
我想知道UILongPressGestureRecognitor被压入了哪个单元格,我无法向其中添加标签,是否有一些聪明的方法可以找到这些信息?您将其添加到单元格中,因此该单元格就是识别器的视图:
- (void)longPressHandler:(UILongPressGestureRecognizer *)gr {
UITableViewCell *cell = (UITableViewCell *)gr.view;
// ...
}
您可以对UITableViewCell进行子类化,并添加一个变量,该变量保存您试图从tableviewcell获取的任何信息。然后,您只需获取
indexPathForCell
,就可以获得可能需要的所有信息