2011-03-10 52 views
0

大概只是一个简单的问题,但我一直在构建一个小型益智游戏,没有决定我可以做一个菜单。我创建菜单没有问题,我只是不能让它在拼图之前显示。我试着改变appdelegate中的代码,但不喜欢它。加载一个新的观点之前,旧的一个iphone sdk

滑块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; 
} 

但这样做,抛出一个错误:

error: request for member 'view' in something not a structure or union

我知道它可能是一个愚蠢的问题,但可能任何人请帮助。

回答

0

您需要导入类,使的alloc的对象第一次看到这个

滑块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] [email protected]"MainMenu" bundle:nil] autorelease]; // and here 
    [self.window addSubview:viewController1.view]; 
    [self.window makeKeyAndVisible]; 

    return YES; 
} 
+0

干杯的是,轻微的问题,但它只是加载一个空白屏幕不屏幕所有的按钮。 – user506926 2011-03-10 11:05:15