1

を使用して別のメソッドから呼び出したいこのジェスチャースワイプメソッドがあります

[self performSelector:@selector(handleSwipeGesture:) withObject:nil afterDelay:10];

@selector()に入れる構文がわかりません

どんな助けでも大歓迎です。ここに私のコードがあります:

 - (IBAction)handleSwipeGesture:(UISwipeGestureRecognizer *)sender { 
        if(sender.direction == UISwipeGestureRecognizerDirectionLeft) {
            NSLog(@"swipe left");
            TutorialMenuViewController *tutorialMenuViewController = [[TutorialMenuViewController alloc]
                                                          initWithNibName:@"TutorialMenuViewController" bundle:nil];
            [self.navigationController pushViewController:tutorialMenuViewController animated:YES];
            [tutorialMenuViewController release];
        }
    }
4

2 に答える 2

2
- (IBAction)handleSwipeGesture:(UISwipeGestureRecognizer *)sender { 
if(sender.direction == UISwipeGestureRecognizerDirectionLeft) {
    NSLog(@"swipe left");
    //TutorialMenuViewController *tutorialMenuViewController = [[TutorialMenuViewController alloc]
    //                                                        initWithNibName:@"TutorialMenuViewController" bundle:nil];
    //[self.navigationController pushViewController:tutorialMenuViewController animated:YES];
    //[tutorialMenuViewController release];
}
}

次のように呼び出します。

 UISwipeGestureRecognizer *leftSwipe  =  [[UISwipeGestureRecognizer alloc] initWithTarget:nil action:nil];
[leftSwipe setDirection:(UISwipeGestureRecognizerDirectionLeft)];
[self performSelector:@selector(handleSwipeGesture:) withObject:leftSwipe afterDelay:1];
[leftSwipe release];
于 2012-05-21T10:25:38.720 に答える
2

ジェスチャーまたは時間遅延のいずれかで提示したい場合はTutorialMenuViewController、その提示を別の方法に抽象化する方がよいでしょう

- (IBAction)handleSwipeGesture:(UISwipeGestureRecognizer *)sender { 
    if(sender.direction == UISwipeGestureRecognizerDirectionLeft) {
        [self presentTutorial];
    }
}

- (void)presentTutorial;
{
    TutorialMenuViewController *tutorialMenuViewController = [[TutorialMenuViewController alloc]
                                                      initWithNibName:@"TutorialMenuViewController" bundle:nil];
    [self.navigationController pushViewController:tutorialMenuViewController animated:YES];
    [tutorialMenuViewController release];
}

これで、簡単に呼び出すことができます

[self performSelector:@selector(presentTutorial) withObject:nil afterDelay:10];
于 2012-05-21T10:22:07.507 に答える