我正在创建在属性列表中有引号的应用程序,当我按下下一个按钮时它会显示在 UIText 中,另一个引号会出现在 textview 中,但是现在我想在用户根据该动作向左或向右滑动引号时添加手势。我是 iphone 新手。我已经使用viewpagger在android中完成了它。任何人都知道这个我怎么能做到..提前谢谢。
user2199128
问问题
118 次
2 回答
2
您可以使用 UISwipeGestureRecognizer 来完成。确保您的 textView 不可编辑。
代码如下:
UISwipeGestureRecognizer *leftSwipe = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(leftSwipe)];
[leftSwipe setDirection:UISwipeGestureRecognizerDirectionLeft];
[_textView addGestureRecognizer:leftSwipe];
UISwipeGestureRecognizer *rightSwipe = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(rightSwipe)];
[rightSwipe setDirection:UISwipeGestureRecognizerDirectionRight];
[_textView addGestureRecognizer:rightSwipe];
- (void) leftSwipe
{
NSLog(@"leftSwipe");
}
- (void) rightSwipe
{
NSLog(@"rightSwipe");
}
现在相应地显示您的报价。
于 2013-04-01T06:02:01.600 回答
0
为您的报价添加动画:
首先将 QuartzCore 框架导入您的项目。
#import <QuartzCore/QuartzCore.h>
现在修改滑动方法如下:
- (void) leftSwipe
{
NSLog(@"leftSwipe");
[self curlAnimationFromLeft];
}
- (void) rightSwipe
{
NSLog(@"rightSwipe");
[self curlAnimationFromRight];
}
- (void) curlAnimationFromLeft
{
CATransition *animation = [CATransition animation];
[animation setDelegate:self];
[animation setDuration:1.0];
[animation setTimingFunction:UIViewAnimationCurveEaseInOut];
animation.type = @"pageCurl";
animation.subtype = @"fromRight";
animation.fillMode = kCAFillModeForwards;
[animation setRemovedOnCompletion:YES];
[_textView.layer addAnimation:animation forKey:@"pageCurlAnimation"];
}
-(void)curlAnimationFromRight
{
CATransition *animation = [CATransition animation];
[animation setDelegate:self];
[animation setDuration:1.0];
[animation setTimingFunction:UIViewAnimationCurveEaseInOut];
animation.type = @"pageUnCurl";
animation.subtype = @"fromRight";
animation.fillMode = kCAFillModeForwards;
animation.startProgress = 0.35;
[animation setRemovedOnCompletion:NO];
[_textView.layer addAnimation:animation forKey:@"pageUnCurlAnimation"];
}
于 2013-04-01T06:41:08.283 回答