登录ios的UINavigationController流 [英] UINavigationController flow for login ios

查看:52
本文介绍了登录ios的UINavigationController流的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

已解决:

用户登录/注册后,请使用以下代码过渡到主故事板...

once the user has logged in / signed up, use the following code to transition to the main storyboard...

 UIWindow* window = [[UIApplication sharedApplication] keyWindow];

 window.rootViewController = [[UIStoryboard storyboardWithName:@"Main" bundle:[NSBundle mainBundle]] instantiateInitialViewController];

我有以下UINavigationController流来处理登录...在tabbarcontroller转到uinavigationcontroller之后的最重要的部分,该uinavigationcontroller是viewcontroller的根.

I have the following UINavigationController flow to handle logging in...the top segue after the tabbarcontroller goes to a uinavigationcontroller that is the root for a viewcontroller.

当用户已经登录时,将执行此搜索工作",以便用户不必在登录屏幕上登录.那很好.我遇到的问题是用户必须登录时...从登录/注册屏幕到登录屏幕的顺序运行正常,但是当我从登录屏幕转到选项卡栏时,会发生以下情况:

When the user is already logged in the "this segue works" is executed so that the user doesn't have to log in at the login screen. That works perfectly. The issue I run into is when the user has to login...the segue from the login/signup screen to the login screen works perfectly, but when I go from the login screen to the tabbar the following happens:

这真的不应该发生,因为我的viewcontroller.m中有以下代码(称为调用")

This really shouldn't happen because I have the following code in my viewcontroller.m (gotten to here is called)

- (void)viewDidLoad {
    ...
    self.navigationItem.title = @"Messages";
    self.navigationItem.hidesBackButton = YES;

    NSLog(@"gotten to here");
    ...
}

有人知道为什么会这样吗?

Does anybody know why this is happening?

推荐答案

我希望将登录流程与常规应用流程分开.这意味着我不会将登录界面从搜索屏幕链接到应用程序,而是在AppDelegate中处理该问题:

I like to keep my login flow separate from the normal app flow. This means that I don't link a segue from the login screen to the app, but I handle that in my AppDelegate:

if ([MyUserHandler sharedHelper].isAuthenticated) {
    [self presentMainInterface];
} else {
    [self presentWelcomeInterface];
}

第一种方法是在哪里进行

Where the first method does this:

- (void)presentMainInterface
{
    self.window.rootViewController = [[UIStoryboard storyboardWithName:@"Main" bundle:[NSBundle mainBundle]] instantiateInitialViewController];
}

,另一个显示登录屏幕:

and the other presents the login screen:

- (void)presentWelcomeInterface
{   
    UIViewController* rootController = [[UIStoryboard storyboardWithName:@"Main" bundle:[NSBundle mainBundle]] instantiateViewControllerWithIdentifier:@"loginScreen"];

    UINavigationController* navigation = [[UINavigationController alloc] initWithRootViewController:rootController];
    self.window.rootViewController = navigation;
}

这样,仅当用户未通过身份验证时,才会加载登录屏幕.

This way the login screen is loaded only when the user is not authenticated.

这篇关于登录ios的UINavigationController流的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆