Could not load NIB in bundle: 'NSBundle ··· with name 'chosenCountry''

后端 未结 3 1331
你的背包
你的背包 2021-01-29 05:09

I want touch the UIBarButtonItem in the top right, and push a new viewController. So, the code is:

UIBarButtonItem *addButton = [[UIBarButtonItem a         


        
相关标签:
3条回答
  • 2021-01-29 05:32

    Since you have added your vc in storyboard, hence initWithNibName will not work.

    Either use segue or use storyboard's method instantiateViewControllerWithIdentifier to instantiate the view controller

    0 讨论(0)
  • 2021-01-29 05:51

    Use this code it works for you

    UIStoryboard *mainStoryboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
    yourViewController *vc = [mainStoryboard instantiateViewControllerWithIdentifier:@"chosenCountry"];
    [self.navigationController pushViewController:vc animated:YES];
    
    0 讨论(0)
  • 2021-01-29 05:53
    UIStoryboard *sb = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
     UIViewController *vc = [sb instantiateViewControllerWithIdentifier:@"chosenCountry"];
     [self.navigationController pushViewController:vc animated:YES];
    
    0 讨论(0)
提交回复
热议问题