gpt4 book ai didi

iphone - Ios5滑动手势

转载 作者:行者123 更新时间:2023-11-28 19:18:12 25 4
gpt4 key购买 nike

我目前正在编写一个 ios5 应用程序并使用按钮调用两个函数 (back) 和 (next)。我想用滑动手势给他们打电话。

这可能吗?如何实现?

谢谢

最佳答案

向右方向(下一步按钮)和向左方向(后退按钮)使用滑动手势对于左方向:

UISwipeGestureRecognizer *swipeLeft =[[UISwipeGestureRecognizer alloc]
initWithTarget:self action:@selector(didSwipeLeft:)];
swipeLeft.direction=UISwipeGestureRecognizerDirectionLeft;
swipeLeft.numberOfTouchesRequired = 1;
[self.view addGestureRecognizer:swipeLeft];
[swipeLeft release];

对于正确的方向:

UISwipeGestureRecognizer *swipeRight =[[UISwipeGestureRecognizer alloc]
initWithTarget:self action:@selector(didSwipeRight:)];
swipeRight .direction=UISwipeGestureRecognizerDirectionRight;
swipeRight .numberOfTouchesRequired = 1;
[self.view addGestureRecognizer:swipeRight ];
[swipeRight release];

你用事件来处理它们:

 -(void)didSwipeRight
{
//For right direction (next button)
}

-(void)didSwipeLeft
{
//For left direction (back button)
}

关于iphone - Ios5滑动手势,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10990060/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com