0

会发生什么;当我向左滑动时,textView 会更改帧大小,这是我想要它做的,但是当我向右滑动时,textView 并没有变回我想要的方式,实际上它根本没有改变!
有什么帮助吗?

// Add swipeGestures
    UISwipeGestureRecognizer *SwipeLeft = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(swipeReconised:)];
    [SwipeLeft setDirection:UISwipeGestureRecognizerDirectionLeft];
    [self.view addGestureRecognizer:SwipeLeft];

    UISwipeGestureRecognizer *SwipeRight = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(swipeReconised:)];
    [SwipeRight setDirection:UISwipeGestureRecognizerDirectionRight];
    [self.view addGestureRecognizer:SwipeRight];
}
- (void)swipeReconised:(UISwipeGestureRecognizer *)Swipe {
if (Swipe.direction == UISwipeGestureRecognizerDirectionLeft) {
    CGRect frame = [TextView frame];
    frame.size.width = 750;//Some value
    frame.size.height = 655;//some value
    frame.origin.x = 275;
    frame.origin.y = 44;
    [TextView setFrame:frame];
if (Swipe.direction == UISwipeGestureRecognizerDirectionRight) {
    CGRect frame = [TextView frame];
    frame.size.width = 240;//Some value
    frame.size.height = 655;//some value
    frame.origin.x = 784;
    frame.origin.y = 44;
    [TextView setFrame:frame];
        }
    }
}
4

1 回答 1

1

打开 prase ofif (Swipe.direction == UISwipeGestureRecognizerDirectionLeft)应该在此之前关闭,if (Swipe.direction == UISwipeGestureRecognizerDirectionRight)只有它被调用

- (void)swipeReconised:(UISwipeGestureRecognizer *)Swipe {
if (Swipe.direction == UISwipeGestureRecognizerDirectionLeft) {
    CGRect frame = [TextView frame];
    frame.size.width = 750;//Some value
    frame.size.height = 655;//some value
    frame.origin.x = 275;
    frame.origin.y = 44;
    [TextView setFrame:frame];
}
if (Swipe.direction == UISwipeGestureRecognizerDirectionRight) {
    CGRect frame = [TextView frame];
    frame.size.width = 240;//Some value
    frame.size.height = 655;//some value
    frame.origin.x = 784;
    frame.origin.y = 44;
    [TextView setFrame:frame];
    }
}
于 2012-10-29T04:38:06.657 回答