How iOS programs start

Source: Internet
Author: User

1.info.plist

After building a project, you will see a "project name-info.plist" file under the supporting Files folder, which is very important for the project to do some run-time configuration, so it is not possible to remove common attributes (the red part is the key you see when you open it with a text editor) · In the old version of Xcode created by the project, the name of this configuration file is called "Info.plist" • Other plist files in the project cannot have the word "Info", or they will be mistaken for the legendary "Info.plist" · There is also a infoplist.strings file in the project, which is related to localization of info.plist files Localiztion native development region (cfbundledevelopmentregion)-Localization-related Bundle display name (Cfbundledisplayname)-The name of the program is displayed after installation, limited to 10-12 characters, if exceeded, will be displayed abbreviated name Uicon file (Cfbundleiconfile)-app icon name, typically icon.png Bundle version (cfbundleversion)-The version number of the application, each time a new version is posted to the App Store, you need to add this version number Main storyboard file base name (Nsmainstoryboardfile)-The name of the main storyboard file Bundle identifier (Cfbundleidentifier)-The unique identification of the project, to deploy to the real machine using the 2.Pch files • The project's supporting files folder has a "project name-prefix.pch" file, and also a header file pch the contents of the header file can be shared and accessed by all other source files in the project • Generally define some global macros in the PCH file • Add the following preprocessing directives to the PCH file and then use the log (...) in the project. To output the log information, the NSLog statement can be removed at once when the application is published (debug mode is defined)

#ifdef DEBUG

#define LOG (...) NSLog (__va_args__)

#else

#define LOG (...)/* */

#endif

3. What is UIApplication

The UIApplication object is the symbol of the application • Each application has its own UIApplication object, and it is a single case (UIApplication sharedapplication) to obtain the singleton object. The first object created after an iOS program is started is the UIApplication object • Use the UIApplication object to perform some application-level operations Common Properties 4. The status bar starts with IOS7, The system provides 2 ways to manage the status bar through Uiviewcontroller management (each uiviewcontroller can have its own different status bar) through UIApplication management (the status bar of an application is managed by it uniformly)

In IOS7, by default, the status bar is managed by Uiviewcontroller, and Uiviewcontroller implements the following methods to easily manage the visibility of the status bar and the style of the style status bar

-(Uistatusbarstyle) Preferredstatusbarstyle;

Visibility of the status bar-(BOOL) prefersstatusbarhidden;  If you want to use uiapplication to manage the status bar, you first need to modify the settings of the Info.plist   5.openurl   6.uiapplication and delegate  all mobile operating systems have a fatal disadvantage: The app is very vulnerable to interruptions. For example, a call or lock screen will cause the app to enter the background or even be terminated. There are many other similar situations that can cause the app to be disturbed, and when the app is disturbed, it generates some system events, and UIApplication notifies its delegate object. Let the delegate agent handle these system events delegate events that can be handled include: Ø Application lifecycle events (such as program startup and shutdown) Ø system events (such as incoming calls) Ø memory warning    each new project, there is a " Appdelegate "The class of words, it is uiapplication agent  appdelegate default has complied with the Uiapplicationdelegate protocol, is already uiapplication agent   The  7.uiapplicationmain main function executes a uiapplicationmain this function  int uiapplicationmain (int argc, char *argv[] , NSString *principalclassname, NSString *delegateclassname), argc, argv: Transfer directly to Uiapplicationmain for related processing   Principalclassname: Specifies the application class name (symbol of the app), which must be uiapplication (or subclass). If nil, the UIApplication class is used as the default value  delegateclassname: Specifies the application's proxy class, which must comply with the Uiapplicationdelegate protocol   The Uiapplicationmain function creates a UIApplication object based on Principalclassname and creates a delegate object from Delegateclassname. and assigns the delegate object to the DELE in the UIApplication objectGate Properties   Then builds the application's main Runloop (event loop) to handle the event (the application of the delegate object is called first after the program finishes: Didfinishlaunchingwithoptions: Method)   Program exits normally uiapplicationmain function returns   8.uiwindow  UIWindow is a special kind of uiview, usually in one app only one UIWindow iOS program is started, the first view control created is UIWindow, then the controller's view is created, Finally, the controller's view is added to the UIWindow, so the controller's view is displayed on the screen. • An iOS program can be displayed on the screen entirely because it has uiwindow and says that without UIWindow, you can't see any UI interface   • Add UIView to UIWindow in two common ways: ø-(void) Addsubview: (UIView *) view;

The view is added directly to the UIWindow, but the view corresponding Uiviewcontroller is not ignored

Ø@property (Nonatomic,retain) Uiviewcontroller *rootviewcontroller;

Automatically add Rootviewcontroller view to UIWindow, responsible for managing the Rootviewcontroller lifecycle

• Common Methods-(void) Makekeywindow;

Make current UIWindow into Keywindow (main window)

-(void) makekeyandvisible;

Make the current UIWindow into Keywindow and show it

[UIApplication sharedapplication].windows

A list of UIWindow that opens in this app so you can touch any of the UIView objects in your app

(usually input text pop-up keyboard, in a new UIWindow)

[uiapplication Sharedapplication].keywindow

The UIWindow used to receive message events for keyboards and non-touch classes, and only one uiwindow per time in a program is Keywindow. If a text box inside a UIWindow cannot enter text, it may be because this uiwindow is not Keywindow

View.window

Get the UIWindow where a uiview is located

How iOS programs start

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.