gpt4 book ai didi

iphone - 在进入 Storyboard 中的场景之前检查用户是否已登录

转载 作者:行者123 更新时间:2023-11-29 04:02:19 24 4
gpt4 key购买 nike

首先,我使用 Storyboard进行导航。我已经到了这样的地步:我在一个菜单屏幕上,其中有 2 个 View 有 4 个不同的 View (仅带有导航 Controller ),我希望它检查用户是否已登录,如果没有,我想要 LoginViewController/查看提出。我对 Objective C/xcode 非常陌生,在寻找解决方案后,这就是我想到的。我不知道如何将其与我的程序联系起来。这是否只需要链接到我的按钮,还是我完全不做我现在正在做的事情?

if (self.appDelegate.userHasActiveLogin) {
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
UIViewController *vc = [storyboard instantiateViewControllerWithIdentifier:@"ViewController2"];
[vc setModalPresentationStyle:UIModalPresentationFullScreen];

[self presentModalViewController:vc animated:YES];}
else {
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
UIViewController *vc = [storyboard instantiateViewControllerWithIdentifier:@"LoginController"];
[vc setModalPresentationStyle:UIModalPresentationFullScreen];

[self presentModalViewController:vc animated:YES];
}

最佳答案

您可以做的是在 Storyboard中创建手动转场。

按住 Ctrl 键并从菜单 Controller (橙色符号)拖动到子 Controller ,然后选择推送。单击 segue 并在属性检查器中为其指定一个标识符。现在,您可以检查用户是否已登录,然后有条件地在菜单的 VC 中调用 [self PerformSegueWithIdentifier:@"logged in segue"sender:self];

条件是所有 VC 必须在同一个 Storyboard中,但我怀疑情况确实如此。

关于iphone - 在进入 Storyboard 中的场景之前检查用户是否已登录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15710829/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com