简体   繁体   English

iPhone应用程序-应用程序加载后立即将视图加载到另一个视图中

[英]iPhone App - load View into Another View as soon as app has loaded

I have a rootviewcontroller and a loginviewcontroller. 我有一个rootviewcontroller和一个loginviewcontroller。 As soon as my app has finished loading up, I would like the rootviewcontroller to load the loginview associated with the loginviewcontroller. 我的应用程序完成加载后,我希望rootviewcontroller加载与loginviewcontroller关联的loginview。 This is because the very first screen will be the user login..... 这是因为第一个屏幕将是用户登录.....

How is this possible? 这怎么可能?

The application flow should be as follows: 申请流程应如下:

rootViewController -----immediately loads-----> loginviewcontroller -------user logs in--------> taken to mainmenuviewcontroller rootViewController -----立即加载-----> loginviewcontroller -------用户登录-------->进入mainmenuviewcontroller

The rootviewcontroller contains all the other controllers because it essentially holds global variables that store the results of processes carried out by other objects... rootviewcontroller包含所有其他控制器,因为它实际上持有全局变量,该变量存储由其他对象执行的处理结果...

It depends on your overall UI architecture. 这取决于您的整体UI架构。

Without having much information, given the fact that it is a login view, I would push it as a modal view. 考虑到它是一个登录视图,因此如果没有太多信息,我会将其作为模式视图进行推送。 Look at this document for more info . 请参阅此文档以获取更多信息

In short, you can call presentModalViewController:animated: on your rootviewcontroller and pass it the loginviewcontroller . 简而言之,您可以在rootviewcontroller上调用presentModalViewController:animated: rootviewcontroller并将其传递给loginviewcontroller The login view controller will then be shown on top of the root view controller. 然后,登录视图控制器将显示在根视图控制器的顶部。

[rootViewController presentModalViewController:loginViewController animated:YES];

You should provide a way for your login view controller then to be dismissed and return control to the root view controller. 您应该为登录视图控制器提供一种解散然后将控制权返回给根视图控制器的方法。

If u want to use first screen as login view and second one is root view controller then u use code as 如果您想使用第一个屏幕作为登录视图,第二个是根视图控制器,则您使用代码作为

- (void)applicationDidFinishLaunching:(UIApplication *)application {    

viewController= [[loginViewController alloc] init];
UINavigationController *nc = [[UINavigationController alloc] initWithRootViewController:viewController];
[window addSubview:nc.view];
[window makeKeyAndVisible];

} and then in loginViewController.m file call rootviewcontroller. },然后在loginViewController.m文件中调用rootviewcontroller。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM