gpt4 book ai didi

iPhone模拟器向右滑动可以,但向左滑动不行?

转载 作者:行者123 更新时间:2023-12-03 18:24:34 24 4
gpt4 key购买 nike

我正在尝试在 UIScrollView 上左右滑动。然而,看起来向左滑动在 iPhone 模拟器中不起作用,尽管向右滑动可以。我错过了什么步骤吗?

- (void)viewWillAppear:(BOOL)animated {    [super viewWillAppear:animated];    self.scrollView.multipleTouchEnabled = YES;    UISwipeGestureRecognizer *swipe = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(handleSwipe:)];    swipe.delaysTouchesBegan = YES;    swipe.numberOfTouchesRequired = 2;    [self.scrollView addGestureRecognizer:swipe];    [swipe release];}- (void)handleSwipe:(UISwipeGestureRecognizer *)recognizer{    if (recognizer.direction == UISwipeGestureRecognizerDirectionLeft) {    } else if (recognizer.direction == UISwipeGestureRecognizerDirectionRight) {    }}

最佳答案

使用以下内容:

UISwipeGestureRecognizer *rightRecognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(rightSwipeHandle:)];
rightRecognizer.direction = UISwipeGestureRecognizerDirectionRight;
[rightRecognizer setNumberOfTouchesRequired:1];
[mainSlideShowImageScrollView addGestureRecognizer:rightRecognizer];
[rightRecognizer release];
UISwipeGestureRecognizer *leftRecognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(leftSwipeHandle:)];
leftRecognizer.direction = UISwipeGestureRecognizerDirectionLeft;
[leftRecognizer setNumberOfTouchesRequired:1];
[mainSlideShowImageScrollView addGestureRecognizer:leftRecognizer];
[leftRecognizer release];



- (void)rightSwipeHandle:(UISwipeGestureRecognizer*)gestureRecognizer
{
//Do moving
}

- (void)leftSwipeHandle:(UISwipeGestureRecognizer*)gestureRecognizer
{
// do moving
}

关于iPhone模拟器向右滑动可以,但向左滑动不行?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6577773/

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