01.
02.
03.
04.
05.
06.
07.
08.
09.
#import "ViewController.h"
10.
11.
@interface
ViewController ()
12.
13.
@end
14.
15.
@implementation
ViewController
16.
17.
- (
void
)viewDidLoad
18.
{
19.
[
super
viewDidLoad];
20.
21.
22.
UISwipeGestureRecognizer
*swipeLeft = [[
UISwipeGestureRecognizer
alloc]
23.
initWithTarget:
self
24.
action:
@selector
(swipeLeftHandle:)];
25.
swipeLeft.direction =
UISwipeGestureRecognizerDirectionLeft
;
26.
[[
self
view] addGestureRecognizer:swipeLeft];
27.
[swipeLeft release];
28.
29.
UISwipeGestureRecognizer
*swipeRight = [[
UISwipeGestureRecognizer
alloc]
30.
initWithTarget:
self
31.
action:
@selector
(swipeRightHandle:)];
32.
swipeRight.direction =
UISwipeGestureRecognizerDirectionRight
;
33.
[[
self
view] addGestureRecognizer:swipeRight];
34.
[swipeRight release];
35.
36.
UISwipeGestureRecognizer
*swipeUp = [[
UISwipeGestureRecognizer
alloc]
37.
initWithTarget:
self
38.
action:
@selector
(swipeUpHandle:)];
39.
swipeUp.direction =
UISwipeGestureRecognizerDirectionUp
;
40.
[[
self
view] addGestureRecognizer:swipeUp];
41.
[swipeUp release];
42.
43.
UISwipeGestureRecognizer
*swipeDown = [[
UISwipeGestureRecognizer
alloc]
44.
initWithTarget:
self
45.
action:
@selector
(swipeDownHandle:)];
46.
swipeDown.direction =
UISwipeGestureRecognizerDirectionDown
;
47.
[[
self
view] addGestureRecognizer:swipeDown];
48.
[swipeDown release];
49.
}
50.
51.
-(
void
) swipeLeftHandle:(
UISwipeGestureRecognizer
*) sender {
52.
if
(sender.direction ==
UISwipeGestureRecognizerDirectionLeft
)
53.
lblResult.text = @
"swipe left"
;
54.
NSLog
(@
"swipe left"
);
55.
}
56.
57.
-(
void
) swipeRightHandle:(
UISwipeGestureRecognizer
*) sender {
58.
if
(sender.direction ==
UISwipeGestureRecognizerDirectionRight
)
59.
lblResult.text = @
"swipe right"
;
60.
NSLog
(@
"swipe right"
);
61.
}
62.
63.
-(
void
) swipeUpHandle:(
UISwipeGestureRecognizer
*) sender {
64.
if
(sender.direction ==
UISwipeGestureRecognizerDirectionUp
)
65.
lblResult.text = @
"swipe up"
;
66.
NSLog
(@
"swipe up"
);
67.
}
68.
69.
-(
void
) swipeDownHandle:(
UISwipeGestureRecognizer
*) sender {
70.
if
(sender.direction ==
UISwipeGestureRecognizerDirectionDown
)
71.
lblResult.text = @
"swipe down"
;
72.
NSLog
(@
"swipe down"
);
73.
}
74.
75.
- (
void
)didReceiveMemoryWarning
76.
{
77.
[
super
didReceiveMemoryWarning];
78.
79.
}
80.
81.
- (
void
)dealloc {
82.
[lblResult release];
83.
[
super
dealloc];
84.
}
85.
@end