【发布时间】:2016-05-30 11:21:31
【问题描述】:
我想触摸右上角的UIBarButtonItem,然后推送一个新的viewController。所以,代码是:
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];
}
但是当我运行'Could not load NIB in bundle:'NSBundle ...(loaded)' with name 'chosenCountry''时,XCode 出现错误 我该如何解决? 谢谢!
【问题讨论】:
-
你有一个名为
chosenCountry的xib文件吗? -
我认为您的 viewconrtoller 名称是 selectedViewController。试试这个 selectedViewController
-
@Larme 我不知道,我在 storyboard 中拖了一个新的视图控制器,并将它的类设置为 selectedViewController。我该怎么办?非常感谢
-
那么,和那个有关:stackoverflow.com/questions/9896406/…?
-
@MAuLIK 如果将其更改为 selectedViewController,Xcode 甚至不让我运行
标签: ios objective-c