码迷,mamicode.com
首页 > 移动开发 > 详细

ios手势识别之轻扫

时间:2016-01-23 23:03:18      阅读:234      评论:0      收藏:0      [点我收藏+]

标签:

 1 - (void)viewDidLoad
 2 {
 3     [super viewDidLoad];
 4     
 5     // 向上
 6     UISwipeGestureRecognizer *swipe = [[UISwipeGestureRecognizer alloc] init];
 7     // 设置轻扫的方向
 8     swipe.direction = UISwipeGestureRecognizerDirectionUp;
 9     [self.customView addGestureRecognizer:swipe];
10     [swipe addTarget:self action:@selector(swipeView)];
11     
12     // 向下
13     UISwipeGestureRecognizer *swipe2 = [[UISwipeGestureRecognizer alloc] init];
14     // 设置轻扫的方向
15     swipe2.direction = UISwipeGestureRecognizerDirectionDown;
16     [self.customView addGestureRecognizer:swipe2];
17     [swipe2 addTarget:self action:@selector(swipeView2)];
18     
19     // 左边
20     UISwipeGestureRecognizer *swipe3 = [[UISwipeGestureRecognizer alloc] init];
21     // 设置轻扫的方向
22     swipe3.direction = UISwipeGestureRecognizerDirectionLeft;
23     [self.customView addGestureRecognizer:swipe3];
24     [swipe3 addTarget:self action:@selector(swipeView3)];
25     
26     // 右边
27     UISwipeGestureRecognizer *swipe4 = [[UISwipeGestureRecognizer alloc] init];
28     // 设置轻扫的方向
29     swipe4.direction = UISwipeGestureRecognizerDirectionRight;
30     [self.customView addGestureRecognizer:swipe4];
31     [swipe4 addTarget:self action:@selector(swipeView4)];
32     
33     
34     
35 }
36 - (void)swipeView4
37 {
38     NSLog(@"轻扫事件右");
39 }
40 
41 - (void)swipeView3
42 {
43     NSLog(@"轻扫事件左");
44 }
45 
46 - (void)swipeView2
47 {
48     NSLog(@"轻扫事件下");
49 }
50 
51 - (void)swipeView
52 {
53     NSLog(@"轻扫事件上");
54 }

 

ios手势识别之轻扫

标签:

原文地址:http://www.cnblogs.com/PJHome/p/5154059.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!