开发者

Cannot send parameter from touchesEnded

im trying to send a parameter from my touchesEnded handler like so...

    - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {

    UITouch *touch = [touches anyObject];
    CGPoint currentPosition = [touch locationInView:self.view];
    CGFloat deltaX = fabsf(gestureStartPoint.x - currentPosition.x);
    CGFloat deltaY = fabsf(gestureStartPoint.y - currentPosition.y);
    if (deltaX >= 0.3 && deltaY <= 100) { //horizontal swipe detected

               [self performSelector:@selector(refreshCover:)
                   withObject:nil afterDelay:0];
        if (gestureStartPoint.x < currentPosition.x) { //swipe right
            [self refreshCover:@"backward"];
            NSLog(@"swipe backward");
   开发者_运维技巧     } else { //swipe left
            [self refreshCover:@"forward"];
            NSLog(@"swipe forward");
        }       
    }
}

then in refreshCover, i just have :

    - (void)refreshCover:(NSString*)direction {

    NSLog(@"direction: %@", direction);
}

when a user swipes, refreshCover is called, but the direction parameter is not getting passed. if i call [self refreshCover:@"forward"] from anywhere else, the parameter is passed without problems.

any ideas? thanks in advance.


The problem is with this code

[self performSelector:@selector(refreshCover:)
               withObject:nil afterDelay:0];

The performSelector will call the function. I think this code is not needed since you are calling the function individually

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜