Xamarin.ios登录页,无法更改故事板的第一页
我正在使用xamarin.ios创建一个应用程序。我的故事板中有一些页面,我已经将其中一个页面的“Is initial View Controller”设置为第一个页面。 如果用户已经登录,则将该页面视为第一页,否则我希望显示登录页面。为此,我添加了以下代码:Xamarin.ios登录页,无法更改故事板的第一页,ios,xamarin,xamarin.ios,uistoryboard,Ios,Xamarin,Xamarin.ios,Uistoryboard,我正在使用xamarin.ios创建一个应用程序。我的故事板中有一些页面,我已经将其中一个页面的“Is initial View Controller”设置为第一个页面。 如果用户已经登录,则将该页面视为第一页,否则我希望显示登录页面。为此,我添加了以下代码: [Export ("application:didFinishLaunchingWithOptions:")] public bool FinishedLaunching (UIApplication ap
[Export ("application:didFinishLaunchingWithOptions:")]
public bool FinishedLaunching (UIApplication application, NSDictionary launchOptions)
{
this.Window = new UIWindow(UIScreen.MainScreen.Bounds);
LoginViewController yourViewController = UIStoryboard.FromName("Main", NSBundle.MainBundle).InstantiateViewController("LoginViewController") as LoginViewController;
this.Window.RootViewController = yourViewController;
this.Window.MakeKeyAndVisible();
return true;
}
问题是,此代码根本无法更改第一页。我的应用程序似乎总是忽略这段代码,并在情节提要上显示“Is Initial View controller”等于true的页面。这意味着当我在故事板上更改第一页时,我看到了更改,但在代码中设置时没有更改。应用程序代理的角色从iOS 12更改为iOS 13,应用程序代理负责设置应用程序的场景:
[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();
}
以下是swift中关于这个问题的一些线索:和
和文章:和应用程序代理的角色从iOS 12更改为iOS 13,负责设置应用程序的场景:
[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();
}
以下是swift中关于这个问题的一些线索:和
和文章:和您是否使用iOS13在模拟器中测试代码?是的,我是这样做的。我用的是windows模拟器。你用iOS13在模拟器中测试你的代码吗?是的,我用。我使用windows模拟器。