所以我对这个故事板概念还很陌生。我有一个视图笔尖放入情节提要中,每个视图笔尖都对应于我拥有的 UIViewController 子类,我尝试使用以下代码加载笔尖文件:
TestViewController *vc = [[TestViewController alloc] initWithNibName:@"TestViewController" bundle:nil];
[self.view setBackgroundColor:[UIColor blueColor]];
[self.view setFrame:CGRectMake(0, self.profilePicture_.frameHeight + self.profilePicture_.frameY + 10, self.scrollView_.frameWidth, 100)];
[self.view addSubview:vc.view];
但是,它给了我以下错误:
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Could not load NIB in bundle: 'NSBundle </Users/aditya15417/Library/Application Support/iPhone Simulator/5.1/Applications/64E6CEC9-E6DC-4AF5-BF16-11BFB6415BDC/Pulse.app> (loaded)' with name 'TestViewController''
所以问题是,如果我的笔尖在故事板中,是否无法使用 initWithNibName ?如果有办法的话,我该怎么做?
请用
[self.storyboard instantiateViewControllerWithIdentifier:@"some identifier you set in IB"];
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)