Objective c 在自定义视图Xcode中加载
这是针对Mac应用程序的,而不是针对iPhone。我想做的是获取我当前的xib“欢迎屏幕”,当它打开时,在一个名为myTargetView的自定义视图中加载另一个xib“WelcomeScreenText1”。运行时,错误消息为“[NSViewController loadView]加载了“WelcomeScreenText1”xib,但未设置任何视图。”请帮助Objective c 在自定义视图Xcode中加载,objective-c,xcode,macos,Objective C,Xcode,Macos,这是针对Mac应用程序的,而不是针对iPhone。我想做的是获取我当前的xib“欢迎屏幕”,当它打开时,在一个名为myTargetView的自定义视图中加载另一个xib“WelcomeScreenText1”。运行时,错误消息为“[NSViewController loadView]加载了“WelcomeScreenText1”xib,但未设置任何视图。”请帮助 #import "WelcomeMainViewController.h" #import "WelcomeText1ViewCont
#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
该消息表示nib没有将任何东西连接到视图控制器的
视图
出口
在nib中,确保文件所有者的自定义类设置为WelcomeMainViewController
。然后确保文件所有者的视图
出口连接到nib的顶级视图