不显示AppDelegate中的第一个ViewController



我有一个内部涂成红色的UIViewController,我想把这个viewController看作第一个屏幕,但从来没有从viewController开始,我做错了什么?

UIWindow window;
[Export("window")]
public UIWindow Window { get; set; }
[Export("application:didFinishLaunchingWithOptions:")]
public bool FinishedLaunching(UIApplication application, NSDictionary launchOptions)
{
window = new UIWindow(UIScreen.MainScreen.Bounds);
View view = new View();
UINavigationController navigationMain = new UINavigationController(view);

window.MakeKeyAndVisible();
window.RootViewController = navigationMain;
return true;
}

我得到这个错误:

Proyect[4195:115403] SecTaskLoadEntitlements failed error=22 cs_flags=200, pid=4195
Proyect[4195:115403] SecTaskCopyDebugDescription: Proyect[4195]/0#-1 LF=0
Proyect[4195:115403] SecTaskLoadEntitlements failed error=22 cs_flags=200, pid=4195
Proyect[4195:115403] SecTaskCopyDebugDescription: Proyect[4195]/0#-1 LF=0

在iOS 13(及更高版本(上,场景代理将接管应用程序委派。最重要的是,窗口的概念是被场景的替换。一个应用程序可以有多个场景,并且场景现在用作应用程序的用户界面的背景所容纳之物

从iOS 13开始,SceneDelegate负责设置应用程序的场景,以及设置它们的初始视图。

[Export ("scene:willConnectToSession:options:")]
public void WillConnect (UIScene scene, UISceneSession session, UISceneConnectionOptions connectionOptions)
{
// Use this method to optionally configure and attach the UIWindow `window` to the provided UIWindowScene `scene`.
// If using a storyboard, the `window` property will automatically be initialized and attached to the scene.
// This delegate does not imply the connecting scene or session are new (see UIApplicationDelegate `GetConfiguration` instead).
UIWindowScene myScene = scene as UIWindowScene;
Window = new UIWindow(myScene);
UIViewController viewController = new UIViewController();
UINavigationController navigationMain = new UINavigationController(viewController );
Window.RootViewController = navigationMain;
Window.MakeKeyAndVisible();
}

有关更多信息,您可以阅读本文并观看iOS13 中优化应用程序发布的官方视频

最新更新