根据启动时的用户登录状态启动不同的情节提要 (Xamarin.iOS)



我正在将我的Android应用程序转换为iOS。我已经创建了登录屏幕,用户可以登录。如果他输入正确的凭据,则使用NSUSerDefault存储其数据。

我不知道的是,当应用程序启动时,它如何实现它检查 NSUserDefault 的值并决定用户是否必须登录。

由于 Segues 不能像在 Android (StartActivity() ) 中那样以编程方式制作,并且需要一个按钮或类似的东西,我的问题的解决方案是什么?

on AppDelegate class:

public override bool FinishedLaunching(UIApplication application, NSDictionary launchOptions)
        {
            // Override point for customization after application launch.
            // If not required for your application you can safely delete this method

            UIViewController yourViewController = UIStoryboard.FromName("yourStoryboard",NSBundle.MainBundle).InstantiateViewController("yourViewController_StoryboardID");

            this.Window = new UIWindow(UIScreen.MainScreen.Bounds);
            UINavigationController navigationController = new UINavigationController(yourViewController);
            this.Window.RootViewController = navigationController;
            this.Window.MakeKeyAndVisible();

            return true;
        }

最新更新