繁体   English   中英

导航控制器之前的iOS初始登录视图

[英]iOS initial log in view before navigational Controller

我已经玩了几天,但我无法弄清楚。

->基本上,我想实现一个简单的登录视图,单击该按钮时会带有一个按钮,然后转到导航控制器(在我的情况下是“ viewController”,其中的按钮链接到其他视图的迷你数学游戏)。

->在单击登录屏幕上的按钮时,应首先显示登录屏幕,而不是导航控制器的根视图

->单击登录屏幕上的按钮时,我试图声明导航控制器,但这似乎不起作用

->可以肯定地说,导航控制器只能在apple委托中初始化吗?

目前,我在苹果代表中声明并设置了导航控制器:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:       (NSDictionary *)launchOptions
{
    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    // Override point for customization after application launch.
    self.viewController = [[ViewController alloc] initWithNibName:@"ViewController" bundle:nil];
    UINavigationController *navigationViewController = [[UINavigationController alloc] initWithRootViewController:self.viewController];  // self.viewController is the main screen
    self.window.rootViewController = navigationViewController; // set root to navigationViewController
    [self.window makeKeyAndVisible];

    return YES;
}

任何想法将不胜感激。 感谢您的时间 !

您在应用程序委托中的代码看起来不错。 NavigationController无需在AppDelegate中声明。 在您的情况下,绝对可以在按下登录按钮时声明它。

在登录事件上尝试以下操作:

UIViewController *nextVC = [[UIViewController alloc] init];
UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:nextVC];
[self presentViewController:navController animated:YES completion:^{

}];

我要做的是将loginViewController设置为导航的rootViewController。 并且在检查登录是否成功完成之后,您可以实现[self performSegueWithIdentifier:@“ identifier”],将游戏viewController设置为目标。 (使用情节提要将使您的生活更加轻松)。 好吧,这是我的意见:)

暂无
暂无

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

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