你没有说它是如何崩溃的——但我假设你有一段ModelNotImplementedException
时间使用该Window
属性,因为它不是默认实现的(并且适用于情节提要)。
您可以实现它以返回window
(自动生成的)AppDelegate
(AppDelegate.cs 文件)的字段,或者将相同的变量公开为(静态)字段。
例如默认生成的代码
UIWindow window;
public override bool FinishedLaunching (UIApplication app, NSDictionary options)
{
window = new UIWindow (UIScreen.MainScreen.Bounds);
window.RootViewController = new UINavigationController ();
window.MakeKeyAndVisible ();
return true;
}
会成为:
static UIWindow window;
public override bool FinishedLaunching (UIApplication app, NSDictionary options)
{
window = new UIWindow (UIScreen.MainScreen.Bounds);
window.RootViewController = new UINavigationController ();
window.MakeKeyAndVisible ();
return true;
}
static public UIWindow Window {
get { return window; }
}