Created
December 2, 2010 03:03
-
-
Save dannvix/724673 to your computer and use it in GitHub Desktop.
iPhone Hello World Application
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// copyed from "iPhone Developer's Cookbook", Addison-Wesley 2009 | |
#import <UIKit/UIKit.h> | |
@interface HelloWorldViewController : UIViewController | |
@end | |
@implementation HelloWorldViewController | |
- (void) loadView | |
{ | |
UIView *contentView = [[UIView alloc] initWithFrame: [[UIScreen mainScreen] applicationFrame]]; | |
contentView.backgroundColor = [UIColor lightGrayColor]; | |
UILabel *label = [[UILabel alloc] initWithFrame: CGRectMake(0.0f, 0.0f, 320.0f, 30.0f)]; | |
label.text = @"Hello World"; | |
label.center = contentView.center; | |
label.textAlignment = UITextAlignmentCenter; | |
label.backgroundColor = [UIColor clearColor]; | |
[contentView addSubview: label]; | |
[label release]; | |
self.view = contentView; | |
[contentView release]; | |
} | |
@end | |
@interface HelloWorldAppDelegate : NSObject <UIApplicationDelegate> | |
@end | |
@implementation HelloWorldAppDelegate | |
- (void) applicationDidFinishLaunching:(UIApplication *) application | |
{ | |
UIWindow *window = [[UIWindow alloc] initWithFrame: [[UIScreen mainScreen] bounds]]; | |
HelloWorldViewController *hwvc; | |
hwvc = [[HelloWorldViewController alloc] init]; | |
[window addSubView: hwvc.view]; | |
[window makeKeyAndVisible]; | |
} | |
@end | |
int main (int argc, char *argv[]) | |
{ | |
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; | |
int retVal = UIApplicationMain(argc, argv, nil, @"HelloWorldAppDelegate"); | |
[pool release]; | |
return retVal; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment