ITeye博客

最简单iphone程序

wilent · 2012-08-25 12:54 · iphone · 移动开发 · Markdown

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;
}

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。