Use code to create an App Window on the iPhone

Source: Internet
Author: User
Tags mail code

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:

 
 
  1. Convert the original line:
  2. Int retVal = UIApplicationMain (argc, argv, nil, nil );
  3. Changed:
  4. Int retVal = UIApplicationMain (argc, argv, nil, @ "CodingWindowDemoAppDelegate ");

5. After modifying CodingWindowDemoAppDelegate. h, the Code is as follows:

 
 
  1. #import <UIKit/UIKit.h> 
  2. @interface CodingWindowDemoAppDelegate : NSObject <UIApplicationDelegate> {     
  3.  UIWindow *window;}//@property (nonatomic, retain) IBOutlet UIWindow *window;  
  4. @end 

6. After modifying CodingWindowDemoAppDelegate. m, the Code is as follows:

 
 
  1. # Import "CodingWindowDemoAppDelegate. h"
  2. @ Implementation CodingWindowDemoAppDelegate
  3. // @ Synthesize window;
  4. # Pragma mark-
  5. # Pragma mark Application lifecycle
  6. -(BOOL) application :( UIApplication *) application didfinishlaunchingwitexceptions :( NSDictionary *) launchOptions {
  7. // Override point for customization after application launch.
  8. Window = [[UIWindow alloc] initWithFrame: CGRectMake (0, 0,320,480)];
  9. Window. backgroundColor = [UIColor blueColor];
  10. // Add the code for loading the view.
  11. //...
  12. [Window makeKeyAndVisible];
  13. Return YES;
  14. }
  15. # Pragma mark-
  16. # Pragma mark Memory management-(void) dealloc {
  17. [Window release];
  18. [Super dealloc];
  19. }
  20. @ End

Summary:IPhoneCreate with codeAppThe content of Window has been introduced. I hope this article will help you!

Related Article

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.