iOS手势
来源:互联网 发布:数据挖掘导论 豆瓣 编辑:程序博客网 时间:2024/05/01 05:59
#import "RootViewController.h"
@interface RootViewController ()
@end
@implementation RootViewController
- (void)viewDidLoad {
[superviewDidLoad];
UIView *view = [[UIViewalloc]initWithFrame:CGRectMake(10,50,self.view.frame.size.width - 20, 300)];
view.backgroundColor = [UIColorbrownColor];
[self.viewaddSubview: view];
//-------点击手势
UITapGestureRecognizer *tap = [[UITapGestureRecognizeralloc]initWithTarget:selfaction:@selector(touchMe)];
//添加手势到视图
//[view addGestureRecognizer:tap];
//设置点击次数
tap.numberOfTapsRequired =3;
//--------长按手势
UILongPressGestureRecognizer *longPress = [[UILongPressGestureRecognizeralloc]initWithTarget:selfaction:@selector(longTouchMe:)];
longPress.allowableMovement =50;//控制允许滑动的距离
longPress.minimumPressDuration =0.5;//设置长按的时间
//[view addGestureRecognizer:longPress];//添加手势到视图
//--------轻扫手势
UISwipeGestureRecognizer *swipe = [[UISwipeGestureRecognizeralloc]initWithTarget:selfaction:@selector(swipeMe:)];
//设置轻扫的方向
swipe.direction =UISwipeGestureRecognizerDirectionDown;//向下滑
[view addGestureRecognizer:swipe];//添加手势到视图
//再加一个向左的轻扫
UISwipeGestureRecognizer *swipe1 = [[UISwipeGestureRecognizeralloc]initWithTarget:selfaction:@selector(swipeMe:)];
swipe1.direction =UISwipeGestureRecognizerDirectionLeft;
[view addGestureRecognizer:swipe1];
// Do any additional setup after loading the view.
}
//点击手势的方法
- (void)touchMe
{
NSLog(@"点击手势");
}
//长按手势的方法
- (void)longTouchMe:(UILongPressGestureRecognizer *)longPress
{
if (longPress.state ==UIGestureRecognizerStateBegan) {
NSLog(@"长按开始");
} elseif (longPress.state ==UIGestureRecognizerStateChanged) {
NSLog(@"正在滑动");
} else {
NSLog(@"长按结束");
}
}
//轻扫手势的方法
- (void)swipeMe:(UISwipeGestureRecognizer *)swipe
{
//判断轻扫的方向
if (swipe.direction ==UISwipeGestureRecognizerDirectionDown) {
NSLog(@"向下轻扫");
} elseif (swipe.direction ==UISwipeGestureRecognizerDirectionLeft) {
NSLog(@"向左轻扫");
}
}
- (void)didReceiveMemoryWarning {
[superdidReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end
- iOS手势
- ios 手势
- IOS手势
- iOS手势
- iOS手势
- ios 手势
- iOS 手势
- iOS手势
- IOS手势
- iOS手势
- IOS手势
- iOS手势
- ios手势
- iOS手势
- 手势 iOS
- ios 手势
- ios手势
- iOS 手势
- javascript 基本语法
- Centos6.5下安装Memcached完整示例
- 011 - Container With Most Water
- Fresco前传(4)
- iOS 用CornerStone配置SVN,HTTP及svn简单使用说明
- iOS手势
- new Color使用注意事项
- 第六章 注解式控制器详解(4)——跟着开涛学SpringMVC
- Android5.0源码分析—— Zygote进程分析
- windows 下编译 pwlib 和 openh323
- Heads-Up Notification
- android数据库相关几个小问题
- Codefores 539A 字符串基础
- 最小生成树的prim