iphone - 如何从项目内部调用ViewController?

标签 iphone objective-c ios xcode

我的项目中有另一个项目。

enter image description here

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 来捆绑,那么它将在事件项目中搜索该文件。

了解更多信息:https://developer.apple.com/library/mac/#documentation/Cocoa/Reference/Foundation/Classes/NSBundle_Class/Reference/Reference.html

关于iphone - 如何从项目内部调用ViewController?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13453546/

相关文章:

iphone - 由于 "Application exited abnormally with signal 9"或“应用程序异常退出,信号 11 : Segmentation fault"in Iphone 导致应用程序崩溃

objective-c - iOS8(自定义键盘)如何使背景透明?

ios - iOS中的HeightForRowAt和estimatedHeightForRowAt

ios - swift 。让所有类(class)最终?

ios - 如何在不显示中间 View 的情况下展开多个 View

iphone - UIViewController显示两个UITableView

iphone - 当通过 UIWebView 播放电影,然后通过 Airplay 输出到 AppleTV 时,关闭 iPhone 屏幕会停止播放。为什么?

javascript - scrollTop 不适用于 -webkit-overflow-scrolling : touch

iphone - 与 Objective-C 中的头文件和实现文件混淆

ios - iphone 中的自动视频?