我目前在 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/