這裏是我的解決方案。它設置bools swipe_down swipe_up swipe_right swipe_left。請享用。
public void view_swipe_gesture_handler(UIGestureRecognizer sender)
{
var translation = view_swipe_gesture.TranslationInView(this.View);
int x = (int)translation.X;
int y = (int)translation.Y;
int absX = x;
int absY = y;
if (absX < 0)
absX *= -1;
if (absY < 0)
absY *= -1;
bool horizontal, veritical;
horizontal = (absX > absY) ;
veritical = !horizontal;
// Determine up, down, right, or left:
bool swipe_up, swipe_down, swipe_left, swipe_right;
swipe_left = (horizontal && x < 0);
swipe_right = (horizontal && x >= 0);
swipe_up = (veritical && y < 0);
swipe_down = (veritical && y >= 0);
++swipes;
String dir="";
if (swipe_down)
dir = "DOWN";
if (swipe_up)
dir = "UP";
if (swipe_left)
dir = "LEFT";
if (swipe_right)
dir = "RIGHT";
show_debug_status("VIEW SWIPE - swipes=" + swipes
+ " x=" + translation.X + " y=" + translation.Y
+ " DIR=" + dir);
}