Search code examples
iosiphoneipaduinavigationcontrollerpushviewcontroller

Unable to pushViewController iOS


I am using storyboard in my app, : I have Button in my View, On click of button i want to navigate to new View

But when i click on button nothing happens,

Here is my Code:

- (IBAction)JoinClicked:(id)sender{

    JoinWithViewController *detail_view_controller = [[JoinWithViewController alloc] initWithNibName:@"JoinWithViewController" bundle:nil];

    [self.navigationController pushViewController:detail_view_controller animated:YES];
}

Where i am doing mistake , please help.

Thanks in advance.


Solution

  • Set storyboard id of view controller in story board in identity inspector

    Make a reference to your storyboard like

    UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
    

    then to your controller

    YourController *vc = [storyboard instantiateViewControllerWithIdentifier:@"YourController"];// storyboardId
    
    [self.navigationController pushViewController:vc animated:YES];
    

    and you can also make segue and do

    [self performSegueWithIdentifier:@"YourSegueIdentifier" sender:sender/nil];