这适用于Mac应用程序,而不适用于iPhone。我想要做的是拿我当前的xib“欢迎屏幕”,当它打开时,在名为myTargetView的自定义视图中加载另一个xib“WelcomeScreenText1”。当它运行时,错误消息“[NSViewController loadView]加载了”WelcomeScreenText1“xib但没有设置视图。”请帮忙!
#import "WelcomeMainViewController.h"
#import "WelcomeText1ViewController.h"
#import "WelcomeText2ViewController.h"
@implementation WelcomeMainViewController
NSString *const text1Title = @"WelcomeScreenText1";
- (void)awakeFromNib
{
WelcomeText1ViewController* imageViewController =
[[WelcomeText1ViewController alloc] initWithNibName:text1Title bundle:nil];
if (imageViewController != nil)
{
myCurrentViewController = imageViewController;
}
// embed the current view to our host view
[myTargetView addSubview: [myCurrentViewController view]];
// make sure we automatically resize the controller's view to the current window size
[[myCurrentViewController view] setFrame: [myTargetView bounds]];
}
- (NSViewController*)viewController
{
return myCurrentViewController;
}
@end
答案 0 :(得分:2)
该消息表示笔尖未将任何内容连接到视图控制器的view
插座。
在您的笔尖中,确保文件所有者的自定义类设置为WelcomeMainViewController
。然后确保文件所有者的view
出口连接到笔尖的顶级视图。