Ios 将UIViewcontroller推送到UINavigation控制器
我有登录屏幕和忘记密码屏幕。忘记密码屏幕连接到导航控制器,但我的登录屏幕未连接到导航控制器,因此如何将登录屏幕移动到忘记屏幕 这是我的密码Ios 将UIViewcontroller推送到UINavigation控制器,ios,uinavigationcontroller,viewcontroller,Ios,Uinavigationcontroller,Viewcontroller,我有登录屏幕和忘记密码屏幕。忘记密码屏幕连接到导航控制器,但我的登录屏幕未连接到导航控制器,因此如何将登录屏幕移动到忘记屏幕 这是我的密码 forgotpasswod *secondViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"forgotpasswodpage"]; [self.navigationController pushViewController:second
forgotpasswod *secondViewController =
[self.storyboard instantiateViewControllerWithIdentifier:@"forgotpasswodpage"];
[self.navigationController pushViewController:secondViewController animated:YES];
您可以显示视图控制器
let vc : ForgotPassword = storyboard.instantiateViewControllerWithIdentifier("forgotView") as ForgotPassword
let navigationController = UINavigationController(rootViewController: vc)
self.presentViewController(navigationController, animated: true, completion: nil)
对于obj c
ForgotPassword *secondViewController =
[self.storyboard instantiateViewControllerWithIdentifier:@"forgotpasswodpage"];
UINavigationController *controller = [[UINavigationController alloc] initWithRootViewController:secondViewController];
[self presentViewController:controller animated:YES completion:nil];
您可以显示视图控制器
let vc : ForgotPassword = storyboard.instantiateViewControllerWithIdentifier("forgotView") as ForgotPassword
let navigationController = UINavigationController(rootViewController: vc)
self.presentViewController(navigationController, animated: true, completion: nil)
对于obj c
ForgotPassword *secondViewController =
[self.storyboard instantiateViewControllerWithIdentifier:@"forgotpasswodpage"];
UINavigationController *controller = [[UINavigationController alloc] initWithRootViewController:secondViewController];
[self presentViewController:controller animated:YES completion:nil];
如果要将ViewController移动到导航ViewController,请使用presentView控制器 将此代码粘贴到操作方法中
- (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;
}
如果要将ViewController移动到导航ViewController,请使用presentView控制器 将此代码粘贴到操作方法中
- (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;
}
if(floor(NSFoundationVersionNumber)这里的问题是导航控制器为零,因为初始控制器(LoginViewController)不像forgorpassordViewController那样嵌入到导航控制器中
为什么不将LoginViewController嵌入到navigationController中,并将ForgotViewController上的标识符设置为“forgotpasswodpage”,就像您所做的那样
然后,您完全按照代码中的内容进行操作
forgotpasswod *secondViewController =
(forgotpasswod *)[self.storyboard instantiateViewControllerWithIdentifier:@"forgotpasswodpage"];
[self.navigationController pushViewController:secondViewController animated:YES];
另外,我更希望您使用[self.navigationController showViewController:secondViewController动画:是];这里的问题是您的导航控制器为零,因为初始控制器(LoginViewController)没有嵌入到类似forgorpassordViewController的导航控制器中
为什么不将LoginViewController嵌入到navigationController中,并将ForgotViewController上的标识符设置为“forgotpasswodpage”,就像您所做的那样
然后,您完全按照代码中的内容进行操作
forgotpasswod *secondViewController =
(forgotpasswod *)[self.storyboard instantiateViewControllerWithIdentifier:@"forgotpasswodpage"];
[self.navigationController pushViewController:secondViewController animated:YES];
另外,我更希望您使用[self.navigationController showViewController:secondViewController动画:是]单击忘记密码,只需从故事板将导航控制器设置为应用程序窗口的rootview控制器。它将自动加载连接到导航控制器的视图。单击忘记密码,只需从故事板将导航控制器设置为应用程序窗口的rootview控制器。它将自动自动加载附加到导航控制器的视图。显示您的storyborad场景我有一个登录名并忘记了vc。登录名vc DOW未连接navogationcontroller显示您的storyborad场景我有一个登录名并忘记了vc。登录名vc DOW未连接navogationcontroller