我有登录屏幕并忘记密码screen.forgot密码屏幕连接到导航控制器但我的登录屏幕没有连接到导航控制器所以如何将登录屏幕移动到忘记屏幕
forgotpasswod *secondViewController =
[self.storyboard instantiateViewControllerWithIdentifier:@"forgotpasswodpage"];
[self.navigationController pushViewController:secondViewController animated:YES];
答案 0 :(得分:1)
您可以呈现视图控制器
let vc : ForgotPassword = storyboard.instantiateViewControllerWithIdentifier("forgotView") as ForgotPassword
let navigationController = UINavigationController(rootViewController: vc)
self.presentViewController(navigationController, animated: true, completion: nil)
对象是
ForgotPassword *secondViewController =
[self.storyboard instantiateViewControllerWithIdentifier:@"forgotpasswodpage"];
UINavigationController *controller = [[UINavigationController alloc] initWithRootViewController:secondViewController];
[self presentViewController:controller animated:YES completion:nil];
答案 1 :(得分:1)
如果要将ViewController移动到Navigation Viewcontroller而不是使用presentView Controller。
将此代码粘贴到您的操作方法
中- (IBAction)forgotpassword:(id)sender {
forgotpasswod *secondViewController =
[self.storyboard instantiateViewControllerWithIdentifier:@"forgotpasswodpage"];
UINavigationController *controller = [[UINavigationController alloc] initWithRootViewController:secondViewController];
[self presentViewController:controller animated:YES completion:nil];
}
当您尝试此代码时,您也可以更改导航栏颜色
if (floor(NSFoundationVersionNumber) <= NSFoundationVersionNumber_iOS_6_1) {
// iOS 6.1 or earlier
self.navigationController.navigationBar.tintColor = [UIColor colorWithHexString:@"#37B578"];
} else {
// iOS 7.0 or later
self.navigationController.navigationBar.barTintColor = [UIColor colorWithHexString:@"#37B578"];
self.navigationController.navigationBar.translucent = NO;
}
好吧试试这段代码并告诉我发生了什么......
答案 2 :(得分:0)
这里的问题是您的导航控制器是零,因为初始控制器(LoginViewController)没有嵌入像forgorpassordViewController这样的导航控制器中。
为什么不在loginController中嵌入loginInViewController,并将ForgotViewController上的Identifier设置为'forgotpasswodpage',就像你已经完成一样
然后你完全按照代码中的内容进行操作
forgotpasswod *secondViewController =
(forgotpasswod *)[self.storyboard instantiateViewControllerWithIdentifier:@"forgotpasswodpage"];
[self.navigationController pushViewController:secondViewController animated:YES];
另外我更喜欢你使用[self.navigationController showViewController:secondViewController animated:YES];
答案 3 :(得分:0)
点击忘记密码,只需从您的应用程序窗口的根视图控制器中创建导航控制器。它将自动加载附加到导航控制器的视图。