我在 Xamarin Forms 應用程式上使用 Skiasharp。使用 SKTouchAction 我試圖捕獲 SKTouchAction.Pressed 和 SKTouchAction.Released 的持續時間,并查找手勢是否長按。但問題是 SKTouchAction.Released 不會在 Android 上觸發。
protected override void OnTouch(SKTouchEventArgs e)
{
switch (e.ActionType)
{
case SKTouchAction.Moved:
break;
case SKTouchAction.Pressed:
//save current time here
break;
case SKTouchAction.Released:
//Compare time here to check long press
break;
}
}
uj5u.com熱心網友回復:
github上有類似的問題。看來您需要讓作業系統知道您想繼續接收觸摸事件。如:
protected override void OnTouch(SKTouchEventArgs e)
{
e.Handled = true;
switch (e.ActionType)
{
case SKTouchAction.Moved:
break;
case SKTouchAction.Pressed:
//save current time here
break;
case SKTouchAction.Released:
//Compare time here to check long press
break;
}
}
另外,你也可以參考這個案例。
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/525685.html
標籤:xamarinxamarin.formsxamarin.android手势识别滑雪锋利
上一篇:嘗試遍歷陣列并注釋它們
