gpt4 book ai didi

ios - 自定义 View 上的 UIPanGestureRecognizer 从未调用

转载 作者:行者123 更新时间:2023-12-01 16:36:09 26 4
gpt4 key购买 nike

我正在使用 Xamarin对于 iOS我有一个自定义 View (从 UIView 继承),我尝试添加一个简单的 UIPanGestureRecognizer ,看到这个:

UIPanGestureRecognizer panGesture = new UIPanGestureRecognizer (() => Console.WriteLine ("Pan");
this.AddGestureRecognizer(panGesture);

但是“Pan”从未在控制台中显示:/

同样,我有一个自定义 View 。

编辑:
当我移动我的代码时:
UIView myView = new UIView (new RectangleF(0,0,200,200));
myView.BackgroundColor = UIColor.Red;
myView.UserInteractionEnabled = true;

var recognizer = new UIPanGestureRecognizer ((g) => {
Console.WriteLine ("Panning detected");
Console.WriteLine ("Gesture recognizer state: {0}", g.State);
});

myView.AddGestureRecognizer (recognizer);

添加 subview (myView);
UIVIewController这有效://///为什么???

我应该对 UIGestureDelegate 做些什么吗? ?!

最佳答案

您还必须添加以下内容。

objective-c :

[panRecognizer setMinimumNumberOfTouches:1];
[panRecognizer setMaximumNumberOfTouches:1];

根据 Xamarin 语法设置这个东西。

也试试这个。
var panGesture = new UIPanGestureRecognizer (() => Console.WriteLine ("Pan");
this.view.AddGestureRecognizer(panGesture);

请参阅以下链接以获取 Xamarin 中更新的 Pangesture。

http://www.slideshare.net/Xamarin/whats-new-in-xamarinios-miguel

关于ios - 自定义 View 上的 UIPanGestureRecognizer 从未调用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28063786/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com