Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/user-interface/2.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 如何在Objective-c中从另一个方法调用手势滑动方法_Iphone_Objective C_Ios_Uiswipegesturerecognizer - Fatal编程技术网

Iphone 如何在Objective-c中从另一个方法调用手势滑动方法

Iphone 如何在Objective-c中从另一个方法调用手势滑动方法,iphone,objective-c,ios,uiswipegesturerecognizer,Iphone,Objective C,Ios,Uiswipegesturerecognizer,我有一个手势滑动方法,我想用另一个方法调用它 [自执行选择器:@选择器(无手柄擦拭手势:) withObject:nil afterDelay:10] 我想不出放入@selector()的语法。 感谢您的帮助。这是我的密码: - (IBAction)handleSwipeGesture:(UISwipeGestureRecognizer *)sender { if(sender.direction == UISwipeGestureRecognizerDirectionLef

我有一个手势滑动方法,我想用另一个方法调用它

[自执行选择器:@选择器(无手柄擦拭手势:) 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];
        }
    }

如果您想以手势或时间延迟的形式呈现
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];

如果您想以手势或时间延迟的形式呈现
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];
我们这样称呼它:

 UISwipeGestureRecognizer *leftSwipe  =  [[UISwipeGestureRecognizer alloc] initWithTarget:nil action:nil];
[leftSwipe setDirection:(UISwipeGestureRecognizerDirectionLeft)];
[self performSelector:@selector(handleSwipeGesture:) withObject:leftSwipe afterDelay:1];
[leftSwipe release];
我们这样称呼它:

 UISwipeGestureRecognizer *leftSwipe  =  [[UISwipeGestureRecognizer alloc] initWithTarget:nil action:nil];
[leftSwipe setDirection:(UISwipeGestureRecognizerDirectionLeft)];
[self performSelector:@selector(handleSwipeGesture:) withObject:leftSwipe afterDelay:1];
[leftSwipe release];

您必须注册swipeGestureRecognizer才能查看相应的视图。谢谢。下面的语法是什么?[self-performSelector:@selector(HandleSweepSignature:)with object:nil afterDelay:10];有什么问题吗?虽然在传递
nil
对象时不会进入if语句,但调用它是正确的。因此,if语句如下所示,计算结果为false
[[nil direction]==uiswipgestureerecognizerdirectionleft]
您必须为相应的视图注册swipeGestureRecognizer。谢谢。下面的语法是什么?[self-performSelector:@selector(HandleSweepSignature:)with object:nil afterDelay:10];有什么问题吗?虽然在传递
nil
对象时不会进入if语句,但调用它是正确的。因此,if语句如下所示,其计算结果为false
[[nil direction]==uiswipgestureerecognizerdirectionleft]
似乎需要大量不必要的工作来创建和配置一个对象,以便传递一个
if
语句。它还促进了糟糕的设计,因为现在调用方法需要知道它调用的方法如何工作的内部细节。当然,最好的解决方案是引导人们远离糟糕的设计,不管你是提出新问题还是提出新建议。是的,这将是一种将OP想要的东西整合在一起的方法,但这不是解决他们问题的正确方法。我并不想说得太苛刻,我只是想给你一些建设性的反馈,让你在帮助下一个人时牢记在心。我同意。你一点也不苛刻。但有一个疑问,可能会有一种情况,我没有handlesweepshide的源代码。在这种情况下,我该怎么办?如果你看不到源代码,你就不会知道OP需要设置
direction=UISweepGestureRecognitizerDirectionLeft
;)在这种情况下,您可能会通过在帖子下方添加注释来探索更多信息。创建和配置对象只是为了传递
if
语句,这似乎是很多不必要的工作。它还促进了糟糕的设计,因为现在调用方法需要知道它调用的方法如何工作的内部细节。当然,最好的解决方案是引导人们远离糟糕的设计,不管你是提出新问题还是提出新建议。是的,这将是一种将OP想要的东西整合在一起的方法,但这不是解决他们问题的正确方法。我并不想说得太苛刻,我只是想给你一些建设性的反馈,让你在帮助下一个人时牢记在心。我同意。你一点也不苛刻。但有一个疑问,可能会有一种情况,我没有handlesweepshide的源代码。在这种情况下,我该怎么办?如果你看不到源代码,你就不会知道OP需要设置
direction=UISweepGestureRecognitizerDirectionLeft
;)在这种情况下,你可能只需在他们的帖子下方发表评论,以了解更多信息