在旧的iphone sdk之前加载新视图

时间:2011-03-10 10:13:39

标签: iphone xcode sdk

可能只是一个简单的问题,但我一直在建立一个小益智游戏,并没有决定我可以用它的菜单。香港专业教育学院创建菜单没有问题,我只是不能让它在拼图之前展示。我已经尝试更改appdelegate中的代码,但它不喜欢它。

滑块appdelegate.h

 #import <UIKit/UIKit.h>

@class SliderViewController;
@class MainMenu;

@interface SliderAppDelegate : NSObject <UIApplicationDelegate> {
    UIWindow *window;
    MainMenu *viewController1;
}

@property (nonatomic, retain) IBOutlet UIWindow *window;
@property (nonatomic, retain) IBOutlet SliderViewController *viewController;
@property (nonatomic, retain) IBOutlet MainMenu *viewController1;
@end

滑块appdelegate.m

#import "SliderAppDelegate.h"
#import "SliderViewController.h"

@implementation SliderAppDelegate

@synthesize window;
@synthesize viewController;
@synthesize viewController1;


#pragma mark -
#pragma mark Application lifecycle

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {    

    // Override point for customization after application launch.

    // Add the view controller's view to the window and display.
    [self.window addSubview:viewController1.view];
    [self.window makeKeyAndVisible];

    return YES;
}

但这样做会引发错误:

  

错误:请求成员“查看”   不是结构或联合的东西

我知道这可能是一个愚蠢的问题,但任何人都可以帮忙。

1 个答案:

答案 0 :(得分:0)

您需要导入该类并首先对该对象进行分配,请参阅此

滑块appdelegate.m

#import "SliderAppDelegate.h"
#import "SliderViewController.h"
#import "MainMenu.h"//change here

@implementation SliderAppDelegate

@synthesize window;
@synthesize viewController;
@synthesize viewController1;


#pragma mark -
#pragma mark Application lifecycle

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {    

   viewController = [[[MainMenu alloc] initWithNibName@"MainMenu" bundle:nil] autorelease]; // and here
    [self.window addSubview:viewController1.view];
    [self.window makeKeyAndVisible];

    return YES;
}