Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/haskell/10.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
Ios 为什么我能';无法从数组中获取手势状态_Ios_Nsarray_Uigesturerecognizer - Fatal编程技术网

Ios 为什么我能';无法从数组中获取手势状态

Ios 为什么我能';无法从数组中获取手势状态,ios,nsarray,uigesturerecognizer,Ios,Nsarray,Uigesturerecognizer,在我的代码中,我将手势添加到数组中。这就是我提到的: - (void)handlePanGesture:(UIPanGestureRecognizer *)panGestureRecognizer{ [arrayLineGestures addObject:panGestureRecognizer]; [arrayAllGestures addObject:[arrayLineGestures copy]]; } 所以过了一段时间,我想再次使用它们,我使用以下代码:

在我的代码中,我将手势添加到数组中。这就是我提到的:

- (void)handlePanGesture:(UIPanGestureRecognizer *)panGestureRecognizer{
     [arrayLineGestures addObject:panGestureRecognizer];
     [arrayAllGestures addObject:[arrayLineGestures copy]];

   }
所以过了一段时间,我想再次使用它们,我使用以下代码:

for (int i=0; i<[arrayAllGestures count]; i++) {
    for (int k=0;k<[[arrayAllGestures objectAtIndex:i]count]; k++) {
        UIPanGestureRecognizer *panGestureRecognizer=(UIPanGestureRecognizer *)[[arrayAllGestures objectAtIndex:i]objectAtIndex:k];           
        const CGPoint point = [[CCDirector sharedDirector] convertToGL:[panGestureRecognizer locationInView:panGestureRecognizer.view]];
        if (panGestureRecognizer.state == UIGestureRecognizerStateBegan) {Nslog(@"began")}

用于(int i=0;i任何
UIgestureRecognitor
状态
仅在您在处理程序中的时间内有效。传递给您的
PangestureRecognitor
不是状态快照,而是对识别器的对象引用。当您将其存储在数组中并稍后尝试引用时,
tate
无效,因为识别器的生命周期可能已过期


如果遍历数组,您可能会发现所有识别器都是同一个对象。但我不知道这是否可以保证,所以不要依赖于此。

您的问题有点模糊。在添加到数组之前,您在哪里检查了状态?您这样做的确切目的是什么?