Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/43.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone 识别按下my UILongPressGestureRecognitor的单元格,无法向其添加标记_Iphone_Objective C_Ios_Xcode - Fatal编程技术网

Iphone 识别按下my 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;

我将UILongPressGestureRecognitor添加到单元格中,如下所示:

        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
,就可以获得可能需要的所有信息