adi*_*dit 3 iphone objective-c ipad ios
所以我对这个故事板概念很新.我有一个视图nibs放入故事板,每个对应一个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];
Run Code Online (Sandbox Code Playgroud)
但是,它给了我以下错误:
*** 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''
Run Code Online (Sandbox Code Playgroud)
所以问题是,如果我在故事板中有我的笔尖是不可能使用initWithNibName?如果有办法,我该怎么做?
请用
[self.storyboard instantiateViewControllerWithIdentifier:@"some identifier you set in IB"];
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5639 次 |
| 最近记录: |