不显示AppDelegate中的第一个ViewController

问题描述 投票:0回答:1

我有一个涂成红色的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);
            LoginView loginView = new LoginView();
            UINavigationController navigation = new UINavigationController(loginView);


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

这是我的ViewController,怎么了?

public partial class LoginView : UIViewController

    {
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            View.BackgroundColor = UIColor.Red;
        }

我遇到此错误: 2019-11-05 15:15:27.806644-0400 ETracker [4195:115403] SecTaskLoadEntitlements失败error = 22 cs_flags = 200,pid = 41952019-11-05 15:15:27.807241-0400 ETracker [4195:115403] SecTaskCopyDebug描述:ETracker [4195] / 0#-1 LF = 02019-11-05 15:15:27.825039-0400 ETracker [4195:115403] SecTaskLoadEntitlements失败error = 22 cs_flags = 200,pid = 41952019-11-05 15:15:27.825367-0400 ETracker [4195:115403] SecTaskCopyDebug描述:ETracker [4195] / 0#-1 LF = 0

ios xamarin xamarin.ios
1个回答
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 loginView = new UIViewController();
    UINavigationController navigation = new UINavigationController(loginView);
    Window.RootViewController = navigation;
    Window.MakeKeyAndVisible();

}

有关更多信息,您可以阅读this articlewatch the official video of Optimizing App Launch in iOS13

© www.soinside.com 2019 - 2024. All rights reserved.