如何在iOS上调用Rootviewcontroller [英] How to call a Rootviewcontroller on iOS

查看:164
本文介绍了如何在iOS上调用Rootviewcontroller的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的iOS应用程序启动im检查下的用户是注册用户或新用户(如facebook& skype),
比如果用户没有注册,我用我的应用程序代理导航应用程序注册屏幕: / p>

In my iOS application launch im checking wether user is registered user or new user(like facebook & skype), than if user is not register i'm navigating app to register screen with my App delegate:

    if (user != register){

        RegisterViewController *registerViewController = [[RegisterViewController alloc] init];
                RearViewController *rearViewController = [[RearViewController alloc] init];

        UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:registerViewController];

        self.viewController = revealController;

        self.window.rootViewController = self.viewController;

        self.window makeKeyAndVisible];
    }else {

FrontViewController *frontViewController = [[FrontViewController alloc] init];
            RearViewController *rearViewController = [[RearViewController alloc] init];

UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:frontViewController];

RevealController *revealController = [[RevealController alloc] initWithFrontViewController:navigationController rearViewController:rearViewController];

self.viewController = revealController;

self.window.rootViewController = self.viewController;

[self.window makeKeyAndVisible];

}

这种方式如果用户没有注册我现在有注册屏幕作为主窗口,

This way if user is not registereds I now have register screen as a main window,

我的问题是:在用户完成注册后,在我的屏幕顶部获取两个导航控制器

My problem is : after user finish registration im im getting two Navigation controller on top of my screen

im使用:

[[self navigationController] pushViewController:revealController animated:YES];

以将应用程序导航到我的主viewController,因为用户现在已注册,

to navigate application to my main viewController since user is now registered,

如何解决这个问题,是否有其他方法修复注册用户问题

how to fix this and is there any other way to fix register user issue

推荐答案

另一个根视图控制器,为什么不设置它而不是推送到另一个navController堆栈:

As you need another root view controller, why not to set it instead of pushing to another navController stack:

[[UIApplication sharedApplication] keyWindow].rootViewController = revealController;

这篇关于如何在iOS上调用Rootviewcontroller的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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