无法在捆绑中加载NIB

无法在捆绑中加载NIB

本文介绍了无法在捆绑中加载NIB:'NSBundle···名称'chosenCountry''的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想触摸右上角的 UIBarButtonItem ,然后推送一个新的viewController。所以,代码是:

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

UIBarButtonItem *addButton = [[UIBarButtonItem alloc]
                              initWithBarButtonSystemItem:UIBarButtonSystemItemAdd
                              target:self
                              action:@selector(insertNewObject)];
self.navigationItem.rightBarButtonItem = addButton;

和方法 insertNewObject 是:

-(void)insertNewObject{
    chosenViewController *chosenCountry = [[chosenViewController alloc]initWithNibName:@"chosenCountry" bundle:nil];
    //self.chosenViewController = chosenCountry;
    [self.navigationController pushViewController:chosenCountry animated:YES];
}

但是当我运行'无法在捆绑中加载NIB时XCode出错: 'NSBundle ...(已加载)',名称为chosenCountry'
我该如何解决?
谢谢!

but XCode have a error when I run 'Could not load NIB in bundle: 'NSBundle ...(loaded)' with name 'chosenCountry''How can I fix it?Thanks!

推荐答案

UIStoryboard *sb = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
 UIViewController *vc = [sb instantiateViewControllerWithIdentifier:@"chosenCountry"];
 [self.navigationController pushViewController:vc animated:YES];

这篇关于无法在捆绑中加载NIB:'NSBundle···名称'chosenCountry''的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-30 06:37