Multiple View App shows Blank Screen in Simulator

Posted by Brett Coburn on Stack Overflow See other posts from Stack Overflow or by Brett Coburn
Published on 2010-05-20T15:17:15Z Indexed on 2010/05/20 15:20 UTC
Read the original article Hit count: 403

Filed under:
|
|
|
|

Hello;

I am developing a simple app that first shows a menu screen, and when a button is pressed, a game screen appears. I was able to develop the game screen without any issues, but when I changed the code to first display the menu, the simulator showed a blank screen.

I've read all the articles on connecting views with IB but I can't figure this out.

Any help would be appreciated.

This is my code:

//  Pong_Multiple_ViewAppDelegate.h
//  Pong Multiple View
//
//  Created by Brett on 10-05-19.
//  Copyright __MyCompanyName__ 2010. All rights reserved.
//

#import <UIKit/UIKit.h>

@class MenuViewController;

@interface Pong_Multiple_ViewAppDelegate : NSObject <UIApplicationDelegate> {
    UIWindow *window;
 MenuViewController *navigationController;
}

@property (nonatomic, retain) IBOutlet UIWindow *window;
@property (nonatomic, retain) IBOutlet MenuViewController *navigationController;

@end


//
//  Pong_Multiple_ViewAppDelegate.m
//  Pong Multiple View
//
//  Created by Brett on 10-05-19.
//  Copyright __MyCompanyName__ 2010. All rights reserved.
//

#import "Pong_Multiple_ViewAppDelegate.h"
#import "MenuViewController.h"

@implementation Pong_Multiple_ViewAppDelegate

@synthesize window;
@synthesize navigationController;


- (void)application:(UIApplication *)application{    

    // Override point for customization after application launch
 [window addSubview:[navigationController view]];
    [window makeKeyAndVisible];

}


- (void)dealloc {
 [navigationController release];
    [window release];
    [super dealloc];
}


@end

//
//  MenuViewController.h
//  Pong Multiple View
//
//  Created by Brett on 10-05-19.
//  Copyright 2010 __MyCompanyName__. All rights reserved.
//

#import <UIKit/UIKit.h>
#import "GameViewController.h"


@interface MenuViewController : UIViewController {

 GameViewController *gameViewController;
 IBOutlet UIButton *gameButton;

}

@property(nonatomic, retain) GameViewController *gameViewController;
@property(nonatomic, retain) UIButton *gameButton;

-(IBAction)switchPage:(id)sender;

@end

//
//  MenuViewController.m
//  Pong Multiple View
//
//  Created by Brett on 10-05-19.
//  Copyright 2010 __MyCompanyName__. All rights reserved.
//

#import "MenuViewController.h"
#import "GameViewController.h"


@implementation MenuViewController

@synthesize gameViewController;
@synthesize gameButton;


-(IBAction)switchPage:(id)sender{
 if (self.gameViewController==nil) {
  GameViewController *gameView = [[GameViewController alloc]initWithNibName:@"GameView" bundle:[NSBundle mainBundle]];
  self.gameViewController= gameView;
  [gameView release];

 }

 [self.navigationController pushViewController:self.gameViewController animated:YES];

}

....

@end 

My code also includes classes: GameViewController.h, GameViewController.m, and nib files: MenuView.xib, and GameView.xib

Thanks, B

© Stack Overflow or respective owner

Related posts about multiview

Related posts about xcode