issue #580 add RootViewController to xcode4 templates

This commit is contained in:
Walzer 2011-06-24 11:38:23 +08:00
parent d4aa30a850
commit 37e5c21aba
14 changed files with 278 additions and 23 deletions

View File

@ -6,8 +6,11 @@
// Copyright ___ORGANIZATIONNAME___ ___YEAR___. All rights reserved. // Copyright ___ORGANIZATIONNAME___ ___YEAR___. All rights reserved.
// //
@interface ___PROJECTNAMEASIDENTIFIER___AppController : NSObject <UIAccelerometerDelegate, UIAlertViewDelegate, UITextFieldDelegate,UIApplicationDelegate> { @class RootViewController;
@interface AppController : NSObject <UIAccelerometerDelegate, UIAlertViewDelegate, UITextFieldDelegate,UIApplicationDelegate> {
UIWindow *window; UIWindow *window;
RootViewController *viewController;
} }
@end @end

View File

@ -11,7 +11,9 @@
#import "EAGLView.h" #import "EAGLView.h"
#import "AppDelegate.h" #import "AppDelegate.h"
@implementation ___PROJECTNAMEASIDENTIFIER___AppController #import "RootViewController.h"
@implementation AppController
#pragma mark - #pragma mark -
#pragma mark Application lifecycle #pragma mark Application lifecycle
@ -32,7 +34,14 @@ static AppDelegate s_sharedApplication;
sharegroup: nil sharegroup: nil
multiSampling: NO multiSampling: NO
numberOfSamples: 0 ]; numberOfSamples: 0 ];
[window addSubview: __glView];
// Use RootViewController manage EAGLView
viewController = [[RootViewController alloc] initWithNibName:nil bundle:nil];
viewController.wantsFullScreenLayout = YES;
viewController.view = __glView;
// Set RootViewController to window
window.rootViewController = viewController;
[window makeKeyAndVisible]; [window makeKeyAndVisible];
[[UIApplication sharedApplication] setStatusBarHidden: YES]; [[UIApplication sharedApplication] setStatusBarHidden: YES];
@ -72,7 +81,6 @@ static AppDelegate s_sharedApplication;
cocos2d::CCDirector::sharedDirector()->startAnimation(); cocos2d::CCDirector::sharedDirector()->startAnimation();
} }
- (void)applicationWillTerminate:(UIApplication *)application { - (void)applicationWillTerminate:(UIApplication *)application {
/* /*
Called when the application is about to terminate. Called when the application is about to terminate.
@ -97,3 +105,4 @@ static AppDelegate s_sharedApplication;
@end @end

View File

@ -0,0 +1,61 @@
//
// ___PROJECTNAMEASIDENTIFIER___AppController.h
// ___PROJECTNAME___
//
// Created by ___FULLUSERNAME___ on ___DATE___.
// Copyright ___ORGANIZATIONNAME___ ___YEAR___. All rights reserved.
//
#import "RootViewController.h"
@implementation RootViewController
/*
// The designated initializer. Override if you create the controller programmatically and want to perform customization that is not appropriate for viewDidLoad.
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
if ((self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil])) {
// Custom initialization
}
return self;
}
*/
/*
// Implement loadView to create a view hierarchy programmatically, without using a nib.
- (void)loadView {
}
*/
/*
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
[super viewDidLoad];
}
*/
// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return UIInterfaceOrientationIsLandscape( interfaceOrientation );
}
- (void)didReceiveMemoryWarning {
// Releases the view if it doesn't have a superview.
[super didReceiveMemoryWarning];
// Release any cached data, images, etc that aren't in use.
}
- (void)viewDidUnload {
[super viewDidUnload];
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
}
- (void)dealloc {
[super dealloc];
}
@end

5
template/xcode4/cocos2d-x.xctemplate/ios/main.m vendored Executable file → Normal file
View File

@ -9,8 +9,9 @@
#import <UIKit/UIKit.h> #import <UIKit/UIKit.h>
int main(int argc, char *argv[]) { int main(int argc, char *argv[]) {
NSAutoreleasePool *pool = [NSAutoreleasePool new];
int retVal = UIApplicationMain(argc, argv, nil, @"___PROJECTNAMEASIDENTIFIER___AppController"); NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
int retVal = UIApplicationMain(argc, argv, nil, @"AppController");
[pool release]; [pool release];
return retVal; return retVal;
} }

View File

@ -6,8 +6,11 @@
// Copyright ___ORGANIZATIONNAME___ ___YEAR___. All rights reserved. // Copyright ___ORGANIZATIONNAME___ ___YEAR___. All rights reserved.
// //
@interface ___PROJECTNAMEASIDENTIFIER___AppController : NSObject <UIAccelerometerDelegate, UIAlertViewDelegate, UITextFieldDelegate,UIApplicationDelegate> { @class RootViewController;
@interface AppController : NSObject <UIAccelerometerDelegate, UIAlertViewDelegate, UITextFieldDelegate,UIApplicationDelegate> {
UIWindow *window; UIWindow *window;
RootViewController *viewController;
} }
@end @end

View File

@ -11,7 +11,9 @@
#import "EAGLView.h" #import "EAGLView.h"
#import "AppDelegate.h" #import "AppDelegate.h"
@implementation ___PROJECTNAMEASIDENTIFIER___AppController #import "RootViewController.h"
@implementation AppController
#pragma mark - #pragma mark -
#pragma mark Application lifecycle #pragma mark Application lifecycle
@ -32,7 +34,14 @@ static AppDelegate s_sharedApplication;
sharegroup: nil sharegroup: nil
multiSampling: NO multiSampling: NO
numberOfSamples:0 ]; numberOfSamples:0 ];
[window addSubview: __glView];
// Use RootViewController manage EAGLView
viewController = [[RootViewController alloc] initWithNibName:nil bundle:nil];
viewController.wantsFullScreenLayout = YES;
viewController.view = __glView;
// Set RootViewController to window
window.rootViewController = viewController;
[window makeKeyAndVisible]; [window makeKeyAndVisible];
[[UIApplication sharedApplication] setStatusBarHidden: YES]; [[UIApplication sharedApplication] setStatusBarHidden: YES];
@ -96,3 +105,4 @@ static AppDelegate s_sharedApplication;
@end @end

View File

@ -0,0 +1,16 @@
//
// ___PROJECTNAMEASIDENTIFIER___AppController.h
// ___PROJECTNAME___
//
// Created by ___FULLUSERNAME___ on ___DATE___.
// Copyright ___ORGANIZATIONNAME___ ___YEAR___. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface RootViewController : UIViewController {
}
@end

View File

@ -0,0 +1,61 @@
//
// ___PROJECTNAMEASIDENTIFIER___AppController.h
// ___PROJECTNAME___
//
// Created by ___FULLUSERNAME___ on ___DATE___.
// Copyright ___ORGANIZATIONNAME___ ___YEAR___. All rights reserved.
//
#import "RootViewController.h"
@implementation RootViewController
/*
// The designated initializer. Override if you create the controller programmatically and want to perform customization that is not appropriate for viewDidLoad.
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
if ((self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil])) {
// Custom initialization
}
return self;
}
*/
/*
// Implement loadView to create a view hierarchy programmatically, without using a nib.
- (void)loadView {
}
*/
/*
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
[super viewDidLoad];
}
*/
// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return UIInterfaceOrientationIsLandscape( interfaceOrientation );
}
- (void)didReceiveMemoryWarning {
// Releases the view if it doesn't have a superview.
[super didReceiveMemoryWarning];
// Release any cached data, images, etc that aren't in use.
}
- (void)viewDidUnload {
[super viewDidUnload];
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
}
- (void)dealloc {
[super dealloc];
}
@end

View File

@ -9,8 +9,9 @@
#import <UIKit/UIKit.h> #import <UIKit/UIKit.h>
int main(int argc, char *argv[]) { int main(int argc, char *argv[]) {
NSAutoreleasePool *pool = [NSAutoreleasePool new];
int retVal = UIApplicationMain(argc, argv, nil, @"___PROJECTNAMEASIDENTIFIER___AppController"); NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
int retVal = UIApplicationMain(argc, argv, nil, @"AppController");
[pool release]; [pool release];
return retVal; return retVal;
} }

View File

@ -6,8 +6,11 @@
// Copyright ___ORGANIZATIONNAME___ ___YEAR___. All rights reserved. // Copyright ___ORGANIZATIONNAME___ ___YEAR___. All rights reserved.
// //
@interface ___PROJECTNAMEASIDENTIFIER___AppController : NSObject <UIAccelerometerDelegate, UIAlertViewDelegate, UITextFieldDelegate,UIApplicationDelegate> { @class RootViewController;
@interface AppController : NSObject <UIAccelerometerDelegate, UIAlertViewDelegate, UITextFieldDelegate,UIApplicationDelegate> {
UIWindow *window; UIWindow *window;
RootViewController *viewController;
} }
@end @end

View File

@ -11,7 +11,9 @@
#import "EAGLView.h" #import "EAGLView.h"
#import "AppDelegate.h" #import "AppDelegate.h"
@implementation ___PROJECTNAMEASIDENTIFIER___AppController #import "RootViewController.h"
@implementation AppController
#pragma mark - #pragma mark -
#pragma mark Application lifecycle #pragma mark Application lifecycle
@ -32,7 +34,14 @@ static AppDelegate s_sharedApplication;
sharegroup: nil sharegroup: nil
multiSampling: NO multiSampling: NO
numberOfSamples: 0 ]; numberOfSamples: 0 ];
[window addSubview: __glView];
// Use RootViewController manage EAGLView
viewController = [[RootViewController alloc] initWithNibName:nil bundle:nil];
viewController.wantsFullScreenLayout = YES;
viewController.view = __glView;
// Set RootViewController to window
window.rootViewController = viewController;
[window makeKeyAndVisible]; [window makeKeyAndVisible];
[[UIApplication sharedApplication] setStatusBarHidden: YES]; [[UIApplication sharedApplication] setStatusBarHidden: YES];
@ -72,7 +81,6 @@ static AppDelegate s_sharedApplication;
cocos2d::CCDirector::sharedDirector()->startAnimation(); cocos2d::CCDirector::sharedDirector()->startAnimation();
} }
- (void)applicationWillTerminate:(UIApplication *)application { - (void)applicationWillTerminate:(UIApplication *)application {
/* /*
Called when the application is about to terminate. Called when the application is about to terminate.
@ -97,3 +105,4 @@ static AppDelegate s_sharedApplication;
@end @end

View File

@ -0,0 +1,16 @@
//
// ___PROJECTNAMEASIDENTIFIER___AppController.h
// ___PROJECTNAME___
//
// Created by ___FULLUSERNAME___ on ___DATE___.
// Copyright ___ORGANIZATIONNAME___ ___YEAR___. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface RootViewController : UIViewController {
}
@end

View File

@ -0,0 +1,61 @@
//
// ___PROJECTNAMEASIDENTIFIER___AppController.h
// ___PROJECTNAME___
//
// Created by ___FULLUSERNAME___ on ___DATE___.
// Copyright ___ORGANIZATIONNAME___ ___YEAR___. All rights reserved.
//
#import "RootViewController.h"
@implementation RootViewController
/*
// The designated initializer. Override if you create the controller programmatically and want to perform customization that is not appropriate for viewDidLoad.
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
if ((self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil])) {
// Custom initialization
}
return self;
}
*/
/*
// Implement loadView to create a view hierarchy programmatically, without using a nib.
- (void)loadView {
}
*/
/*
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
[super viewDidLoad];
}
*/
// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return UIInterfaceOrientationIsLandscape( interfaceOrientation );
}
- (void)didReceiveMemoryWarning {
// Releases the view if it doesn't have a superview.
[super didReceiveMemoryWarning];
// Release any cached data, images, etc that aren't in use.
}
- (void)viewDidUnload {
[super viewDidUnload];
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
}
- (void)dealloc {
[super dealloc];
}
@end

View File

@ -9,8 +9,9 @@
#import <UIKit/UIKit.h> #import <UIKit/UIKit.h>
int main(int argc, char *argv[]) { int main(int argc, char *argv[]) {
NSAutoreleasePool *pool = [NSAutoreleasePool new];
int retVal = UIApplicationMain(argc, argv, nil, @"___PROJECTNAMEASIDENTIFIER___AppController"); NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
int retVal = UIApplicationMain(argc, argv, nil, @"AppController");
[pool release]; [pool release];
return retVal; return retVal;
} }