UINavigationController,pushViewController错误
我有2个视图控制器
VC1有button
在这个button动作
- (IBAction)clickSearch:(id)sender { NSArray *vc=[self.navigationController viewControllers]; ViewControllerSearch *vcSearch=nil; for (int i=0; i<[vc count]; i++) { UIViewController *tempVC=[vc objectAtIndex:i]; if([tempVC isKindOfClass:[ViewControllerSearch class]]) { vcSearch=[vc objectAtIndex:i]; break; } } if(vcSearch) { [self.navigationController popToViewController:vcSearch animated:YES]; } else { ViewControllerSearch *vc3New= [[ViewControllerSearch alloc]initWithNibName:@"ViewControllerSearch" bundle:[NSBundle mainBundle]]; [self.navigationController pushViewController:vc3New animated:YES]; vc3New = nil; } }
ViewControllerSearch id我的第二个视图控制器。这两个视图与push segue连接。
当我点击这个错误的button。
Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Could not load NIB in bundle: 'NSBundle </Users/Ravi/Library/Application Support/iPhone Simulator/6.0/Applications/42268111-F290-40B8-B893-4649852F762C/coffee break app.app> (loaded)' with name 'ViewControllerSearch''
我该如何解决这个错误?请给我一个主意。
你确定你的Nib叫做“ViewControllerSearch.xib”吗?
你也不需要删除vc3New – 事实上你可能不应该这样做。
更新
…从评论板中加载,如评论中提到的,你需要做这样的事情:
UIStoryboard* storyBoard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil]; ViewControllerSearch* controller = [storyBoard instantiateViewControllerWithIdentifier:@"ViewControllerSearch"];
1)确保故事板标识符与您命名的相匹配2)确保您已经在故事板中为您的控制器设置/使用了正确的标识符
- 如何在IOS中做基本的http
- 为什么MFMailComposeViewController在iOS 8.3上崩溃?
- CocoaPods UIImageView + AFNetworking.h无法识别的select器setImageWithURLRequest
- iOS无线专用分发在下载结束时失败,显示“无法下载…”消息
- 嵌入的YouTubevideo无法在iPad(iOS 7)上播放,而HTML5搜索输入可见
- 减少和过滤
- 在没有MPMediaPickerController的情况下访问用户的iTunes库
- iOS Twitter用户 – 时间线获取v1.1 API
- 根据iOS中的touchid了解哪个用户登录应用