【发布时间】:2012-06-05 14:47:59
【问题描述】:
我正在尝试将 DecelerationEnded 回调与 MT.Dialog 元素上的“Tapped”回调结合使用。我不能让两者同时工作。
当 DecelerationEnded 回调被注释掉时,“轻拍”回调起作用。当它被评论时,“点击”回调不再被触发(而 DecelerationEnded 会)。
当 DecelerationEnded 调用移到 Root 设置之上时,按钮“点击”回调起作用,但 DecelerationEnded 回调不起作用。将回调设置延迟到 ViewWillAppear 也不能解决任何问题。
有什么解决办法吗?
示例代码:
public class TestController : DialogViewController
{
public TestController () : base(UITableViewStyle.Plain, null, true)
{
// Create list of 20 buttons.
Section s = new Section();
for (int i = 0; i < 20; i++ )
{
s.Add(new StringElement("test " + i, () => {
Console.WriteLine("Tapped"); // Tapped callback.
}));
}
Root = new RootElement("Test") {s};
// The following line causes all the "tapped" handlers to not work.
this.TableView.DecelerationEnded += HandleDecelerationEnded;
}
void HandleDecelerationEnded (object sender, EventArgs e)
{
Console.WriteLine ("Deceleration Ended");
}
}
【问题讨论】:
-
我知道这没有帮助,但是当我为这个问题创建一个测试项目时,我得到了同样的奇怪行为。我还尝试了“var dvc = new DialogViewController()”而不是对其进行子类化,但得到了同样的结果。我会再玩一点......
-
感谢您的调查。我已经尝试了我能想到的所有变体来解决这个问题,但没有运气。 DecelerationEnded 似乎也覆盖了其他回调(如 DialogViewController.OnSelection)。
-
我已经下载了 MT.D 源代码,稍后会通过它来查看是否可以找到问题。从我目前看到的情况来看,在 TableView 上添加 any 事件处理程序会干扰 StringElement 的 Selected 事件。
-
感谢迈克的帮助。你挖到什么了吗?
标签: c# ios xamarin.ios monotouch.dialog