2015.12.31 iOS Program preparation (developer.apple.com)

Source: Internet
Author: User

? program startup process
Click the icon on the desktop to find the appropriate app icon
. Main function

? UIApplication class
Every app has exactly one instance of UIApplication
Each application has only one instance object of the UIApplication class
The running application is a UIApplication object.


? Uiapplicationmain
Create a singleton object for the Uiappication object (singleton)

The role of your app ' s application object
. Handle the initial routing of incoming user events
A loop that handles user behavior
. Dispatches action messages forwarded to it by control objects (instances of the Uicontrol Class) to appropriate target OB Jects.
Assigning specific behaviors to specific target objects (passing different events to different UI controls)

? Tasks
Getting the App Instance: Get Singleton objects
Getting the app Delegate: Get application Proxy (the state of the capture program)
Getting App windows: Get window
Controlling and Handling events: Handling Event
Opening a URL Resource: Open external App resource (Safari)
Configuring the user Notification Setting: Configuring Notifications for users
Registering for remote notifications: Remotely notify (QQ message, update Notification)
Registering for local notifications: native notification (alarm)
Managing Background Execution: Managing the execution of the background
Managing Home Screen Quick Actions for 3D Touch: Shortcuts
Controlling App Appearance: the appearance of the hypervisor (status bar, network indication, direction)

Nsstringfromclass converts a class into a string form
Nsstringfromclass ([Appdelegate class])

? Uiapplicationdelegate
The Uiapplicationdelegate protocol defines methods that is called by the Singleton UIApplication object in response to IM Portant events in the lifetime of your app.
Some important events that occur during the execution of the responder program (program startup, entry into the background, activation, memory crunch). )

The app delegate works alongside the app object to ensure your app interacts properly with the system and with other apps.
Application proxies and apps work together to ensure the interaction between the program and the system or other programs

The app delegate is effectively the root object of your app. Like the UIApplication object itself, the app delegate are a singleton object and are always present at runtime.
Application proxy is the root object of the program and is always present throughout the program.

The methods inside the APP delegate should be implemented
The app delegate performs several crucial roles:
. It contains your app ' s startup code.
Can be set in the agent using code
A. The first method that the program loads to invoke (configuration, register server information, read data, configure interface)
It's not running into memory yet.
-(BOOL) Application: (UIApplication *) application willfinishlaunchingwithoptions: (Nullable nsdictionary *) Launchoptions Ns_available_ios (6_0);

Load well, need to configure the displayed interface
-(BOOL) Application: (UIApplication *) application didfinishlaunchingwithoptions: (Nullable nsdictionary *) Launchoptions Ns_available_ios (3_0);

It responds to key changes in the your app. Specifically, it responds to both temporary interruptions and to Chan Ges in the execution state of your apps, such as when your apps transitions from the foreground to the background.
Temporary interruption, state change


It responds to notifications originating from outside the app, such as remote notifications (also known as push Notificati ONS), low-memory warnings, download completion notifications, and more.
External notifications (message push, insufficient memory, background download complete)
Registerforremotenotificationtypes:

IT determines whether state preservation and restoration should occur and assists in the preservation and restoration proc ESS as needed.
Determine if the state (data) of the program should be saved or restored

It responds to events that target the app itself and is not specific to your app's views or view controllers.
Events responding to the application itself
Application:openURL:options:

You can use the it to store your app's central data objects or any content this does not has an owning view controller.
Save the current core data of the program or other data that is not viewcontroller saved

? Uiresponder
The Uiresponder class defines a interface for objects, respond to and handle events.
Interfaces that define object responses and handle events
All UI controls capable of handling events are directly or indirectly inherited from Uiresponder

Two main Event behaviors: Touch events and Motion events
There is both general kinds of Events:touch events and motion events.
? Uievent
Touchesbegan:withevent:,
Touchesmoved:withevent:,
Touchesended:withevent:,
Touchescancelled:withevent:.

Motionbegan:withevent:,
Motionended:withevent:,
Motioncancelled:withevent:.
iOS3.0 Canperformaction:withsender:
IOS 4.0, Uiresponder added the Remotecontrolreceivedwithevent:method for handling Remote-control events.

? Responder Chain Responder Chain
The view has a hierarchical relationship, and the added view overrides the previous view when an event occurs. The first view will receive this event, and if the view does not respond, then continue to pass the event to the next level until UIWindow, if it does not respond, then the event will be discarded, and in the process, as long as there is a response, then the event stops passing.

? Why use a proxy
To simplify the code logic (Apple itself designs the look and feel of the system, leaving the manufacturing, materials, and sales agents out to focus on the core modules)
Inheritance can accomplish the function of the agent (if the use of inheritance, the equivalent of Apple itself has its own manufacturing subsidiaries, materials subsidiaries, sales subsidiaries, to their own management increased difficulty, and can not focus on core competitiveness)

The entire application has only one proxy (the default system gives us the Appdelegate class)


? UIWindow
Manages and coordinates the "an" app displays on a device screen
Manage and coordinate the view shown above the device screen
An application typically has only one window

? Features of the UIWindow
. provide an area for displaying it views
Provides an area to display the view
. Distribute events to the views.
Distributing events to a view
. A UIWindow object must have a main interface set up
Setting the Rootviewcontroller property of a window
. display window
Calling the Makekeyandvisible property

? UIScreen
A UIScreen object defines the properties associated with a hardware-based display
Define some properties with hardware-based display

How to get the home screen of a device
[UIScreen Mainscreen]

How to get the rectangle coordinates of a view
Bounds Property

? The size of the various sets of accessories:
4 (320 * 480)
5 (320 * 568)
6 (375 * 667)
6p (414 * 736)

2015.12.31 iOS Program preparation (developer.apple.com)

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.