我在ios项目中使用oxyplot来绘制一些图表。我需要处理图表上的触摸以在其上添加注释。我正在使用触摸事件,但它无法正常工作。实际上它有时会起作用,有时则不起作用。它一开始就在工作,现在已经不再存在了。有谁知道这个bug可能是什么。
这是代码
myLineChart.series1.TouchStarted += (sender, e) =>
{
myLineChart.xCoordinate = e.Position.X;
myLineChart.yCoordinate = e.Position.Y;
if(myLineChart.series1.Points != null){
timer = new System.Timers.Timer ();
timer.Interval = 400;
timer.Elapsed += (senderr, er) => {
InvokeOnMainThread ( () => {
dialog = new DialogView(View,Language.AddNoteLabel,Language.NotesQuestionLabel,Language.YesButton,Language.NoButton);
dialog.Show();
dialog.firstButton.TouchUpInside += (sender1, e1) => CreateNote ();
dialog.secondButton.TouchUpInside += (sender1, e1) => dialog.Dispose ();
});
timer.Dispose();
};
timer.Enabled = true;
}
e.Handled = true;
};
答案 0 :(得分:0)
您可以考虑处理 OxyPlot.Model.TouchCompleted 事件。
private void HookEvents()
{
this.UnhookEvents();
if (this.plot != null && this.plot.Model != null)
{
this.plot.Model.TouchCompleted += this.PlotModelTouchCompletedHandler;
}
}
private void UnhookEvents()
{
if (this.plot != null && this.plot.Model != null)
{
this.plot.Model.TouchCompleted -= this.PlotModelTouchCompletedHandler;
}
}
private void PlotModelTouchCompletedHandler (object sender, OxyTouchEventArgs e)
{
// Put your logic to add custom node here.
}