0
在我的Xamarin iOS应用程序中,我有一个显示警告对话框的静态辅助方法。如果用户仍未按下“确定”按钮,此对话框需要几秒钟后自动消失。下面是简化的代码片段:UIAlertController没有被解雇
UIAlertController dlg = UIAlertController.Create(title, text,
UIAlertControllerStyle.Alert);
dlg.AddAction(UIAlertAction.Create("OK", UIAlertActionStyle.Cancel, null);
UIApplication.SharedApplication.KeyWindow.RootViewController.
PresentViewController(dlg, true, null);
后来,当计时器到期:
t.Elapsed += (s, e) => {
dlg.DismissViewController(true, null);
};
虽然,该方法DismissViewController
确实得到调用时,对话框不会从屏幕上消失。
我甚至试过打电话dlg.Dispose()
,但这也没有帮助。
有人能帮我理解我失踪的是什么吗?问候。
完美。谢谢。 – Peter