导航 Controller 之前的 iOS 初始登录 View

标签 ios ipad authentication controller navigation

这几天我一直在研究这个问题,但我无法弄清楚。

-> 基本上我想实现一个简单的登录 View ,单击时有一个按钮,转到导航 Controller (在我的例子中是“viewController”,带有链接到其他 View 的迷你数学游戏的按钮)。

-> 在登录屏幕上单击按钮时,应首先显示登录屏幕,而不是导航 Controller 的 Root View

-> 我尝试在单击登录屏幕的按钮时声明导航 Controller ,但这似乎不起作用

-> 只能在 apple delegate 中初始化导航 Controller 是否安全?

目前我在我的 apple delegate 中声明和设置我的导航 Controller :

- (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;
}

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

最佳答案

您在应用委托(delegate)中的代码看起来没问题。 NavigationController 不需要在 AppDelegate 中声明。在您的情况下,在按下登录按钮时声明它绝对可以。

在登录事件中试试这个:

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

}];

关于导航 Controller 之前的 iOS 初始登录 View ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19555415/

相关文章:

ios - Theos tweak 适用于 iPhone 5s 但不适用于 iPad 3

ios - ADAL 代币何时可以共享? (iOS)

iOS subview 自定义过渡

ios - SQLiteManager 中的 DROP 语法错误

ios - 现有的 UITableView 照片网格没有正确旋转?

javascript - 在 iPad 3 上慢 .toggleSLide()

ios - 如何使用 swift 3 删除按钮的图像

iphone - 嵌套block = EXC_BAD_ACCESS

java - java/javascript 中浏览器选项卡的登录控件

用于没有内置身份验证的框架的Python身份验证系统(例如web.py)?