Learn more about the Cocoa Touch Layer

Source: Internet
Author: User

DetailsCocoa TouchLayer is the content to be introduced in this article. First, let's look at the content.Cocoa TouchThe layer contains the key required to create an iOS ApplicationFramework. This layer technology is required to provide the underlying foundation for implementing the visual interface of applications and interacting with advanced system services. When developing an application, do not use a lower-levelFramework, Try to useFramework.

Advanced features

The following sections describe some common features that you may plan to support in your application.

Multi-task

If the application is built on the iPhone SDK 4.0 and later versions, and runs on iOS 4.0 and later versions of the operating system), when you click the Home key, the application will not end, but will switch to the background. For most applications, they are suspended when they enter the background. Enabling the application to reside in the background can avoid subsequent restart processes, and the application can directly activate itself, which greatly improves the overall user experience. In addition, suspending an application can also improve system performance, because suspending an application can minimize power usage and allow foreground applications to get more execution time.

Although the application will be suspended when it enters the background, it can continue to run in the background using the following technologies:

Applications can request a certain amount of time to complete some important tasks.

Applications can declare that a certain service they support requires regular background execution time.

Applications can use local notifications to send notifications to users at a specified time. This method is not required for running the application.

No matter whether the application is suspended or running in the background, no extra work is required to support multiple tasks. However, in some cases, such as insufficient memory), the application may end running. Therefore, the application should be able to exit at any time. This means that many tasks that need to be executed when the application exits must be executed when the application switches to the background. This requires you to implement some new methods in the application delegate to switch the status of the Response Program.

For more information about how to handle background status switching and how to keep applications running in the background, see the iOS application programming guide.

Data Protection

Applications dealing with sensitive user data can use the built-in encryption feature of the device. Some devices may not provide the built-in encryption function) to protect data. If the application specifies that a file is protected, the system will save the file in encrypted format on the disk. When the device is locked, your application and other potential intruders cannot access the file, the system generates a key for your application to access the file.

If you need to implement data protection, applications should work hard to create and manage the data to be protected. It must be able to secure data when it is created and adapt to changes in file accessibility caused by Device Locks or unlocks.

For more information about how an application can add data protection to a file, see Chapter implementing standard application behavior in the iOS application programming guide.

Apple push notification service

In iOS 3.0 and later versions, the apple push notification service can be used to notify users of new information in an application, regardless of whether the application is running or not. With this service, you can push text notifications to the system to trigger sound alerts or add a digital tag on the application icon. In this way, users will know that they should open the application to receive relevant information.

From the design point of view, let the application support push notification contains two parts. First, the iOS application needs to request the system to send a notification to it, and then reasonably configure the application delegate so that it can properly process the notification. These tasks can be done through application delegation and the cooperation of UIApplication objects. Second, you need to provide a server-side process to generate the initial notification. This process runs on your local server. It works with the apple push notification service to generate initial notifications.

For more information about how to configure applications to use remote notifications, see the local notification and push notification programming guide.

Local notification

IOS 4.0 introduces local notifications. A local notification is a supplement to an existing push notification. A common program can generate a notification locally without relying on an external server. When an important event occurs, background applications can use local notifications to attract user attention. For example, a background navigation application can use a local notification to remind users of turning. Applications can also schedule to send local notifications to users at some point in the future, and sending these notifications does not require the application to be in the running state.

Local notifications are independent of your applications. Once a notification is scheduled, the system will send the notification. In addition, when sending notifications, your application does not need to be in the running state.

For more information about how to use local notifications, see the local notification and push notification programming guide.

Gesture Reader

IOS 3.2 introduces a gesture identification device. A gesture identification device is an object bound to a view. It is used to detect common gesture types. After you bind a gesture identification device to a view, you can tell it what action to perform when a gesture occurs. Then, the gesture reader can track the original event and identify the gesture according to the system-defined testing method. To recognize a gesture before introducing the gesture reader, you need to track the original Touch event stream of the view, and then use a complex test method to determine whether these events represent a gesture.

Now, the UIKit framework contains
UIGestureRecognizer
Class, which defines the basic behavior of all gesture identifiers. You can use a custom gesture identification subclass or a subclass defined by the system to process the following standard gestures:

Click (any number of clicks)

Inside or outside (for scaling)

Shake or drag

Touch (in any direction)

Rotate (move your finger in the opposite direction)

Long press

For more information about the gesture identifiers you can use, see the iOS event handling guide.

File Sharing support

Applications can use file sharing to allow users to access user data files of programs. File sharing allows applications to expose applications/Documents to users through iTunes

Directory. In this way, users can move files back and forth between iPad and desktop computers. However, this feature does not allow applications and other applications on the same device to share files. To share files between programs, use the clipboard or document interaction controller object.

You can use the following steps to make the application support file sharing:

Add the UIFileSharingEnabled key to the Info. plist file of the application, and set the key value to YES.

Place the files you want to share in the Documents Files directory of the application.

Once the device is inserted into your computer, iTunes 9.1 displays a File Sharing area in the Apps tab of the selected device.

After that, you can add files to the directory or move the files to the desktop.

If the application supports file sharing, after the file is added to the Documents directory, the application should be able to identify and make appropriate responses. For example, an application can display the content of a new file on the interface. Do not display the file list of the directory to users and ask them what operations they want to perform on the file.

For more information about the UIFileSharingEnabled key, see the information attribute list reference.

Point-to-Point Service

In iOS 3.0 and later versions, the Game Kit framework supports point-to-point connections through Bluetooth. You can use a point-to-point connection to start a communication session with a neighboring device, or use it to implement common features of multiple multiplayer games. Although point-to-point connections are mainly used in games, you can also apply them to other types of applications.

For more information about how to use point-to-point connections in applications, see the Game Kit programming guide. For more information about the Game Kit framework, see "Game Kit framework ".

Standard System View Controller

Many Cocoa Touch layer frameworks contain view controllers that display standard system interfaces. We recommend that you use these view controllers in your applications to provide a consistent user experience for your applications and systems. To perform the following tasks, select a view controller from the framework:

Display or edit contact information-use the View Controller in the Address Book UI framework.

Create or edit calendar events-use the View Controller of the Event Kit UI framework.

Create an email or SMS Message. Use the View Controller in the Message UI framework.

Open or preview the content of a file-use the UIDocumentInteractionController class in the UIKit framework.

Select a photo from your photo library-use the UIImagePickerController class in the UIKit framework.

Take a video clip-use the UIImagePickerController class in the UIKit framework.

For details about how to select a View Controller, see the iOS View Controller Programming Guide. For details about the interface displayed by a specific view controller, refer to the corresponding framework reference.

External Device Support

Devices installed with iOS 3.2 can connect to an external display device through a set of cables supported by devices. When an external device is connected, the application can use its display to display the content. The screen information, including the resolution supported by the screen, can be obtained through the interface of the UIKit framework. You can also associate an application window to a screen through this framework.

The UIScreen class is used to obtain the screen objects of all current screens, including the main screen of the device. Screen objects include screen features that take the screen size and pixel ratio into account ).

You can obtain information about a screen with a specific size pixel ratio from the UIScreenMode class.

You can specify a window (represented by the UIWindow class) to a specific screen. To display the content as an image, you must provide two independent windows to display the same content.

For more information about the supported classes, see the corresponding class descriptions in the UIKit framework reference.

Framework included in the Cocoa Touch Layer

The following sections describe the frameworks included in the Cocoa Touch layer and the services provided by these frameworks.

Address Book UI framework

The Address Book UI framework (AddressBookUI. framework) is a set of Objective-C programming interfaces that can display standard system interfaces for creating or editing contacts. This framework simplifies the work required for applications to display contact information. In addition, it can ensure that the interfaces used by applications are the same as those used by other applications, thereby ensuring cross-platform consistency.

For more information about the Address Book UI framework and how to use it, see the iOS Address Book programming guide and iOS Address Book framework reference.

Event Kit UI framework

IOS 4.0 introduces the Event Kit UI framework EventKitUI. framework), which provides a view control key to display the standard system interface for viewing and editing events. The Event data of the Event Kit framework is the basis for building the framework.

For more information about the Event Kit UI framework classes and methods, see the Event Kit UI framework reference.

Game Kit framework

IOS 3.0 introduces the Game Kit framework (GameKit. framework ). This framework supports point-to-point connections and in-game voice functions. You can use this framework to add point-to-point network functions for applications. Point-to-point connections and in-game voice functions are common in multiplayer games, but you can also consider adding them to non-game applications. This framework provides network functions through a set of simple and powerful classes built on Bonjour, which abstract many network details, this makes it easier for developers without network programming experience to integrate network functions into applications.

For more information about the Game Kit framework, see the Game Kit programming guide and the Game Kit framework reference.

IAd framework

IOS 4.0 introduces the iAd framework (iAd. framework ). You can use this framework to publish banner ads in applications. Advertisements are placed in standard views. You can add these views to the user interface and present them to users at the right time. These views work with Apple's announcement service to automatically load and display ad content, and respond to users' clicks on ads.

For more information about how to use iAd in applications, see the iAd framework reference.

Map Kit framework

IOS 3.0 imports the Map Kit framework (MapKit. framework), which provides a Map interface that can be embedded into an application. This interface contains a scrolling Map view. You can add custom information in the view, embed it into the application view, and set various map attributes, including the area displayed on the current map and the user's location, programmatically ). You can also highlight certain areas or additional information in the map using custom or standard annotations, such as using a needle tag.

In the iOS 4.0 system, the framework supports drag-and-drop tagging and custom overwriting. You can drag a tag to allow you to relocate the location of a tag programmatically or through user interaction. A cover layer can be used to create complex map annotations composed of multiple points. Covering layers can be used to display map surfaces, such as bus routes, election maps, park boundaries, or meteorological information such as radar data.

For more information about the classes in the Map Kit framework, see the Map Kit framework reference.

Message UI framework

IOS 3.0 introduces the Message UI framework (MessageUI. framework ). You can use this framework to write emails and put them in the user's sending queue for sending. The framework provides a View Controller Interface, which allows you to display the interface in applications and write emails through the interface. The fields on the page can be generated based on the content of the information to be sent. For example, you can set the recipient, subject, and email content and include attachments in the email. This interface allows you to edit the email and then select accept. After the user accepts the mail content, the corresponding mail will be placed in the user's sending queue for sending.

In iOS 4.0 and subsequent systems, the framework provides an SMS writing panel controller. You can directly create and edit SMS information in the application without leaving the application ). Like the email writing interface, this interface allows you to edit the SMS information before sending it.

For more information about classes in the Message UI framework, see Message UI framework reference.

UIKit framework

UIKit framework(UIKit. Framework) Objective-C programming interface to provide a key basis for iOS application graphics and event-driven. All programs in the iOS system must useFrameworkImplement the following core functions:

Application Management

User Interface Management

Graph and window support

Multi-task support

Handles touch and mobile events.

Objects representing standard system views and controls

Text and web content operations

Cut, copy, and paste

Use animations to Display User Interface content

Integrate other applications to the system through URL

For more information about Alibaba Cloud push notification service, see "Alibaba Cloud push notification service"

Provide auxiliary functions for users with disabilities

Scheduling and sending of local notifications

Create PDF

Using a custom input view, the behavior is similar to that of a system keyboard)

Create a custom text view for interaction with the system keyboard

In addition to the basic code that links to an application,UIKitIt also provides support for the following closely connected features:

Accelerator data

Built-in cameras are equipped with cameras)

User Image Library

Device Name and Model Information

Battery status information

Distance sensor information

Remote control information from the bound Receiver

For more informationUIKit frameworkFor more information, seeUIKit frameworkReference

Summary: DetailsCocoa TouchI hope this article will help you. For more information, see edit recommendations!

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.