---
title: "最简单iphone程序"
author: "wilent"
date: "2012-08-25T12:54:36Z"
tags: []
categories: ["移动开发"]
slug: "iphone"
draft: false
lastmod: "2012-08-25T12:54:36Z"
id: 1662559
url: "https://wilent.iteye.com/blog/1662559"
---

HelloWorldViewController:

```
@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, 32.0f)];
	NSLog(@"addd label..");
	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
```

 

HelloWorldAppDelegate:

```
@interface HelloWorldAppDelegate : NSObject<UIApplicationDelegate>

@end

@implementation HelloWorldAppDelegate

- (BOOL) application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{
	UIWindow *window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; 
	HelloWorldViewController *hwvc;
	hwvc = [[HelloWorldViewController alloc] init];
	[window	addSubview:hwvc.view];
	[window makeKeyAndVisible];
	return YES;
}
@end
```

 main：

```
int main(int argc, char *argv[]) {
    
    NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
    int retVal = UIApplicationMain(argc, argv, nil, @"HelloWorldAppDelegate");
    [pool release];
    return retVal;
}
```