2012-01-22 199 views
0

這適用於Mac應用程序,不適用於iPhone。我想要做的是將我當前的xib「歡迎屏幕」打開,然後在名爲myTargetView的自定義視圖中加載另一個xib「WelcomeScreenText1」。當它運行錯誤消息是「[NSViewController loadView]加載了」WelcomeScreenText1「xib但沒有設置視圖。」請幫忙!在自定義視圖中加載Xcode

#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 

回答

2

該消息表示該筆尖沒有任何東西連接到view出口視圖控制器的。

在您的筆尖中,確保File's Owner的自定義類別設置爲WelcomeMainViewController。然後確保文件所有者的出口連接到筆尖的頂層視圖。

+0

謝謝,忘記了! –

相關問題