我正在尝试在发生异常时显示警告并冒泡到iOS项目。主要
现在假设我在程序
的某处有一个“对象变量未设置异常”它冒泡到MyApp.IOS项目但没有弹出UI警告!!
public class Application
{
static void Main(string[] args)
{
try
{
UIApplication.Main(args, null, "AppDelegate");
}
catch (Exception ex)
{
Task.Run(() =>
{
Device.BeginInvokeOnMainThread(() => {
ShowAlert("MyTitle", ex.ToString(), UIApplication.SharedApplication.KeyWindow.RootViewController);
});
});
}
}
public static UIAlertController ShowAlert(string title, string description, UIViewController controller)
{
UIAlertController alert = UIAlertController.Create(title, description, UIAlertControllerStyle.Alert);
alert.AddAction(UIAlertAction.Create("OK", UIAlertActionStyle.Default, (action) => { }));
controller.PresentViewController(alert, true, null);
return alert;
}
}
我缺少什么想法?
答案 0 :(得分:0)