我对故事板这个概念还比较陌生。我在故事板中添加了一些视图nib文件,每个文件都对应一个我创建的UIViewController子类。我尝试使用以下代码来加载nib文件:
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''
所以问题是,如果我在故事板中有我的 nib 文件,那么是否不可能使用 initWithNibName 方法?如果有方法,应该如何操作?