Loading a new view before the old one iphone sdk
Probably just a simple question, but ive been building a little puzzle game and no decided i could do with a menu for it. Ive created the menu no problem i just cant get it to show before the puzzle. Ive tried changing the code in the appdelegate but its not liking it.
slider 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
Slider 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 cus开发者_如何学Ctomization after application launch.
// Add the view controller's view to the window and display.
[self.window addSubview:viewController1.view];
[self.window makeKeyAndVisible];
return YES;
}
But doing that throws out an error:
error: request for member 'view' in something not a structure or union
I know its probably a stupid question but could anyone help please.
You need to import that class and make alloc the object first see this
Slider 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;
}
精彩评论