1.- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event 
2.{ 
3. UITouch *touch = touches.anyObject; 
4. CGPoint currentTouchPosition = [touch locationInView:self]; 
5. 
6. if (fabsf(startTouchPosition.x - currentTouchPosition.x) >= 
7. HORIZ_SWIPE_DRAG_MIN && 
8. fabsf(startTouchPosition.y - currentTouchPosition.y) <= 
9. VERT_SWIPE_DRAG_MAX) 
10. { 
11. // Horizontal Swipe 
12. if (startTouchPosition.x < currentTouchPosition.x) { 
13. NSLog(@"from left"); 
14. dirString = kCATransitionFromLeft; 
15. } 
16. else 
17. NSLog(@"from right"); 
18. dirString = kCATransitionFromRight; 
19. } 
20. else if (fabsf(startTouchPosition.y - currentTouchPosition.y) >= 
21. HORIZ_SWIPE_DRAG_MIN && 
22. fabsf(startTouchPosition.x - currentTouchPosition.x) <= 
23. VERT_SWIPE_DRAG_MAX) 
24. { 
25. // Vertical Swipe 
26. if (startTouchPosition.y < currentTouchPosition.y) 
27. dirString = kCATransitionFromBottom; 
28. else 
29. dirString = kCATransitionFromTop; 
30. } else 
31. { 
32. // Process a non-swipe event. 
33. // dirString = NULL; 
34. } 
35.} 
36. 
37.- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event 
38.{ 
39. if (dirString) 
40. { 
41. // do it 
42. } 
43.}