IPhoneCreate with codeAppWindow is the content to be introduced in this article. Let's talk about the topic. This example shows how to use the code to createIPhoneOfAppSo that ourAppIt does not rely on any nib file and is fully implemented by mail code.
1. Create a new project "CodingWindowDemo" based on "window-based application ";
2. Delete the MainWindow. xib file;
3. Delete the "Main nib file base name" line in the CodingWindowDemo-Info.plist file;
4. Modify the main. m code:
- Convert the original line:
- Int retVal = UIApplicationMain (argc, argv, nil, nil );
- Changed:
- Int retVal = UIApplicationMain (argc, argv, nil, @ "CodingWindowDemoAppDelegate ");
5. After modifying CodingWindowDemoAppDelegate. h, the Code is as follows:
- #import <UIKit/UIKit.h>
- @interface CodingWindowDemoAppDelegate : NSObject <UIApplicationDelegate> {
- UIWindow *window;}//@property (nonatomic, retain) IBOutlet UIWindow *window;
- @end
6. After modifying CodingWindowDemoAppDelegate. m, the Code is as follows:
- # Import "CodingWindowDemoAppDelegate. h"
- @ Implementation CodingWindowDemoAppDelegate
- // @ Synthesize window;
- # Pragma mark-
- # Pragma mark Application lifecycle
- -(BOOL) application :( UIApplication *) application didfinishlaunchingwitexceptions :( NSDictionary *) launchOptions {
- // Override point for customization after application launch.
- Window = [[UIWindow alloc] initWithFrame: CGRectMake (0, 0,320,480)];
- Window. backgroundColor = [UIColor blueColor];
- // Add the code for loading the view.
- //...
- [Window makeKeyAndVisible];
- Return YES;
- }
- # Pragma mark-
- # Pragma mark Memory management-(void) dealloc {
- [Window release];
- [Super dealloc];
- }
- @ End
Summary:IPhoneCreate with codeAppThe content of Window has been introduced. I hope this article will help you!