ios - 当从 iOS 13.1 中的 SceneDelegate 设置 RootViewController 时,UIElements 变为非事件状态

标签 ios swift xamarin.ios ios13

我目前在 Xamarin.iOS 更新到 iOS 13.1 时遇到这些问题。 当我手动将 LoginController 设置为 Main.Storyboard 中的初始 ViewController 时,一切正常,但是当我将 LoginController 设置为 SceneDelegate.cs 中的 rootViewController 时,当我的应用加载时,所有 UIElement 都将处于非事件状态。

这是我的代码

    [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).

        //// Decide first screen
        UIWindowScene windowScene = new UIWindowScene(session, connectionOptions);

        var window = new UIWindow(windowScene);
        var storyboard = UIStoryboard.FromName("Main", null);

        var registerController = storyboard.InstantiateViewController("LoginViewController") as LoginViewController;
        this.SetWindow(window);


        window.RootViewController = registerController;
        window?.MakeKeyAndVisible();
        window.MakeKeyWindow();

    }

最佳答案

将 View Controller 添加为任何内容的根 Controller 将使您的应用无法导航。 View Controller 用于管理 View 的 Controller ,除非您开发了所述 View Controller 来像导航 Controller 一样管理 View ,并且从它的外观来看,这不是您正在做的。导航 Controller 管理 View Controller 。因此,将根导航 Controller 与该导航 Controller 的根设置为“LoginViewController”,看看会发生什么。另外,停止使用 Storyboard,如果/当您的应用程序达到 100 多个 View Controller 时,您将陷入痛苦的世界。学会以编程方式处理这个问题,您很快就会了解整个导航的工作原理以及如何与 Controller 和 View 交互。

关于ios - 当从 iOS 13.1 中的 SceneDelegate 设置 RootViewController 时,UIElements 变为非事件状态,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58527665/

相关文章:

ios - 发布本地通知时应用程序崩溃

swift - 隐式解包选项和非选项之间的区别

ios - 如何在 textField 上方实现/显示以下弹出窗口?

c# - 使用 monotouch 获取 IPAD 2 的 Mac 地址

ios - 推送通知在开发和生产模式下如何工作(pushwoosh)

ios - UIBezierPath - 你可以 "clip"一个吗?

iphone - Objective C 中的浮点值除法错误

ios - 使用 Metal 的旧设备上的内存使用量不断上升

最初显示 IOS pin 注释,然后使用自定义图像

c# - 图像不保留缩放比例和偏移