标签:
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 }
标签:
原文地址:http://www.cnblogs.com/PJHome/p/5154059.html