我有一个Xamarin应用程序,我试图通过自定义渲染器向相对布局添加滑动手势识别器。
public class MainPageCarouselRenderer : VisualElementRenderer<RelativeLayout>
{
UISwipeGestureRecognizer asd;
UISwipeGestureRecognizer asd2;
protected override void OnElementChanged (ElementChangedEventArgs<RelativeLayout> e)
{
base.OnElementChanged (e);
asd = new UISwipeGestureRecognizer (() => {
e.NewElement.TranslateTo (0, -150, 500, Easing.BounceOut);
});
asd.Direction = UISwipeGestureRecognizerDirection.Up;
asd2 = new UISwipeGestureRecognizer (() => {
e.NewElement.TranslateTo (0, 0, 500, Easing.BounceOut);
});
asd2.Direction = UISwipeGestureRecognizerDirection.Down;
this.AddGestureRecognizer (asd);
this.AddGestureRecognizer (asd2);
}
}
这是我的IOS渲染器中的代码。我调试了这段代码和断点,我把它放在这里。但是当我把断点放在
中时 asd2 = new UISwipeGestureRecognizer (() => {
e.NewElement.TranslateTo (0, 0, 500, Easing.BounceOut);
});
或另一个它没有被击中。有什么想法吗?