Search code examples
iosuinavigationcontrollerviewcontroller

push UIViewcontroller to UINavigation Controller


I have login screen and forgot password screen.forgot password screen is connect to the navigation controller but my login screen not connect to the navigation controller so how to move login screen to forgot screen

enter image description here here is my code

forgotpasswod *secondViewController =
    [self.storyboard instantiateViewControllerWithIdentifier:@"forgotpasswodpage"];

    [self.navigationController pushViewController:secondViewController animated:YES];

Solution

  • If you want to move ViewController to Navigation Viewcontroller than use presentView Controller.

    paste this code in your action method

    - (IBAction)forgotpassword:(id)sender {
    
        forgotpasswod *secondViewController =
        [self.storyboard instantiateViewControllerWithIdentifier:@"forgotpasswodpage"];
    
        UINavigationController *controller = [[UINavigationController alloc] initWithRootViewController:secondViewController];
        [self presentViewController:controller animated:YES completion:nil];
    }
    

    when you try this code than also you can change navigation bar color

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

    ok try this code and tell me what happen...