How to Create a helloworld without XIB;

Source: Internet
Author: User

1. Create an empty application first.

2. Create an objective-C Class

Appdelegate. h

# Import
<Uikit/uikit. h>

# Import
"Viewcontroller. H"

@ Interface appdelegate:
Uiresponder <uiapplicationdelegate>

{


Viewcontroller * viewcontroller;

}

@ Property (strong,
Nonatomic) uiwindow * window;

@ Property (nonatomic, retain) viewcontroller
* Viewcontroller;

@ End

Write appdelegate. m

//

// Appdelegate. m

// Noxibdemo

//

// Created by Wang doublejie on 12-4-8.

// Copyright (c) 2012 _ mycompanyname _. All rights reserved.

//

# Import
"Appdelegate. H"

@ Implementation appdelegate

@ Synthesize window =
_ Window;

@ Synthesize viewcontroller;

-(Void) dealloc

{

[_ Window
Release];

[Super
Dealloc];

}

-(Bool) Application :( uiapplication *) Application didfinishlaunchingwitexceptions :( nsdictionary
*) Launchoptions

{


Self. Window = [[uiwindow
Alloc] initwithframe: [[uiscreen
Mainscreen] bounds]
Autorelease];


// Override point for customization after application launch.


Viewcontroller = [[viewcontroller
Alloc] init];


Viewcontroller. View. bounds =
Cgrectmake (0, 0,320,480 );


Viewcontroller. View. Hidden =
No;


Self. Window. rootviewcontroller =
Self. viewcontroller;

[Self. Window
Makekeyandvisible];


Return yes;

}

-(Void) applicationwillresignactive :( uiapplication *) Application

{


// Sent when the application is about to move from active to inactive state. this can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition
To the background state.


// Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games shocould use this method to pause the game.

}

-(Void) applicationdidenterbackground :( uiapplication *) Application

{


// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.


// If your application supports background execution, this method is called instead of applicationwillterminate: when the user quits.

}

-(Void) applicationwillenterforeground :( uiapplication *) Application

{


// Called as part of the transition from the background to the inactive state; here you can undo changes of the changes made on entering the background.

}

-(Void) applicationdidbecomeactive :( uiapplication *) Application

{


// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previusly in the background, optionally refresh the user interface.

}

-(Void) applicationwillterminate :( uiapplication *) Application

{


// Called when the application is about to terminate. Save data if appropriate. See also applicationdidenterbackground :.

}

@ End

Viewcontroller to create a uitextview; you can see the effect of the Code see http://download.csdn.net/detail/x1135768777/4193676

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.