UISwipeGestureRecognizer和过渡动画

时间:2012-12-14 04:26:04

标签: ios xamarin.ios

我的视图控制器上有一个UISwipeGestureRecognizer。如果我向左滑动或向右滑动,我会负责加载另一个视图并将其显示在屏幕上。

如何添加转场。视图正在ScrollView中加载,ScrollView位于处理转换的主ViewController中。

        MonoTouch.UIKit.UISwipeGestureRecognizer sgrLeft = new MonoTouch.UIKit.UISwipeGestureRecognizer();
        MonoTouch.UIKit.UISwipeGestureRecognizer sgrRight = new MonoTouch.UIKit.UISwipeGestureRecognizer();

        // add the target to it, we put the instance itself of the controller 
        // and the class instance selector
        sgrLeft.AddTarget(this, new Selector("HandleSwipe"));
        sgrRight.AddTarget(this, new Selector("HandleSwipe"));

        // add the swipe direction, there are 4 of them (left, right, up, down). If other than one swipe is 
        // needed then more recognizers must be defined and added to the view - each for the direction
        sgrLeft.Direction = UISwipeGestureRecognizerDirection.Left; 
        sgrRight.Direction = UISwipeGestureRecognizerDirection.Right; 
        // also assign the delegate
        sgrLeft.Delegate = new Helpers.SwipeRecognizerDelegate();
        sgrRight.Delegate = new Helpers.SwipeRecognizerDelegate();

        // and last, add the recognizer to this view to take actions
        this._scrollView.AddGestureRecognizer(sgrLeft);
        this._scrollView.AddGestureRecognizer(sgrRight);

0 个答案:

没有答案