我的项目中有另一个项目。
TutorialViewController *con = [[TutorialViewController alloc] initWithNibName:@"TutorialViewController" bundle:nil WithFrame:CGRectMake(0, 0, 320, 460) AndImages:imageArray PageControlLocation:kPageControlLocationDown WithColor:[UIColor blackColor]];
[self presentModalViewController:con animated:YES];
我想调用这个 TutorialViewController
ViewController
但我认为(知道)编译器找不到这个 Nib ,因为他在主包中找不到它...
有人知道如何调用这个VC
吗?
最佳答案
您必须通过 NSBundle 类显式发送路径,例如:
TutorialViewController *con = [[TutorialViewController alloc] initWithNibName:@"TutorialViewController" bundle:[[NSBundle mainBundle] pathForResource:File_Name ofType:FILE_TYPE inDirectory:your_directory]] WithFrame:CGRectMake(0, 0, 320, 460) AndImages:imageArray PageControlLocation:kPageControlLocationDown WithColor:[UIColor blackColor]];
[self presentModalViewController:con animated:YES];
如果您提供 nil 来捆绑,那么它将在事件项目中搜索该文件。
关于iphone - 如何从项目内部调用ViewController?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13453546/