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
謝謝,忘記了! –