Cocoa touch
Layer includes the construction of IOSProgram. This layer defines the basic structure of the program, supporting key technologies such as multitasking, touch-based input, push notification, and many upper-layer system services. When designing your program, you should first check the technology contained in this layer to see if they meet your needs.
Upper Layer features
The following describes some key technologies of the cocoa touch layer.
◆Multi-task
Ios sdk 4.0 and later SDK build programs (which run on devices of IOS 4.0 and later versions) will not end when you press the Home button; they will be moved to the background for running. The multi-task support supported by uikit allows the program to smoothly switch to the background or back.
To save power, most programs will be suspended immediately after they enter the background. The paused program is still in the memory, but does not execute anyCode. In this way, the program can be quickly restored when it needs to be re-activated, without wasting any power. However, the program can also run in the background for the following reasons:
The program can apply for a limited amount of time to complete some important tasks.
The program can declare a certain service that requires a periodic background running time.
The program can use local notifications to send messages to users at a specified time, regardless of whether the program is running or not.
No matter whether your program is paused or continues running in the background, you do not need to do anything extra to support multiple tasks. The system will notify the program when it is switched to the background or switched back. At this time point, the program can directly execute some important tasks, such as saving user data.
◆Print
From IOS 4.2, uikit introduced print support, allowing programs to send content to nearby printers through wireless networks. For printing, most of the manual work is undertaken by uikit. It manages print interfaces, renders printed content in collaboration with your program, and schedules and executes print jobs in the printer.
The print job submitted by the program is passed to the printing system, which manages the real printing process. Print jobs of all programs on the device are queued and printed first in and out. You can view the print job status from the print center program. All the printed details are automatically processed by the system.
Note: Only devices supporting multiple tasks support wireless printing. Your program can use the uiprintinteractioncontroller object to check whether devices support wireless printing.
◆Data Protection
Ios4.0 introduces the data protection function. Applications that need to process sensitive user data can use the built-in encryption function of some devices (not supported by some devices ). When the program specifies that a file is protected
The system will save the file in encrypted format. When the device is locked, neither your program nor potential intruders can access the data. However, when the device is unlocked by the user, a key is generated
Your program accesses the file.
To achieve good data protection, you need to carefully consider how to create and manage the data you need to protect. Applications must ensure data security when creating data and adapt to changes in file accessibility caused by Device Locks.
◆Apple push notification service
From IOS
Starting from 3.0, Apple released the apple push notification service, which provides a mechanism to send new information to users even if your program has exited. You can use this service at any time
Devices that push text notifications to users can contain program icons as identifiers to send audible alerts. These messages prompt you that you should open your program to receive and view relevant information.
From the design point of view, to enable the IOS program to send push notifications, two parts of work are required. First, the program must request the sending of the notification and be able to process the notification data upon delivery. Then, you need to provide a server process to generate these notifications. This first-class process occurs on your own server and triggers a notification together with Apple's push notification service.
◆Local notification
From IOS
At the beginning of 4.0, Apple launched a local notification. As a supplement to the push notification mechanism, applications can use this method to create notification information locally without relying on an external server. Programs running in the background,
You can use local notifications to remind users of important events. For example, a navigation program running in the background can use local notifications to prompt users to turn. The program can also be scheduled at a certain time in the future
A local notification can be sent even if the program has been terminated.
The advantage of local notification is that it is independent of your program. Once a notification is scheduled, the system manages its sending. When a message is sent, the application is not even running.
◆Gesture Reader
From IOS
Starting from 3.2, a gesture identification device is introduced. You can attach it to the view and use them to detect Common gestures, such as crossing or kneading. After the gesture reader is appended to the view, set the gesture to be executed when it occurs.
Operation. The gesture reader tracks the original Touch events and uses the system presetAlgorithmJudge the current gesture. Without a gesture identification tool, you have to perform these calculations on your own. Many of them are quite complicated.
Uikit contains uigesturerecognizer
Class defines the standard behavior of all gesture identifiers. You can define your own custom gesture identification subclass or use the gesture identification subclass provided by uikit to process the following standard gestures:
◆ Click (any times)
◆ Kneading and Scaling
◆ Pan or drag
◆ Crossing (any direction)
◆ Rotate (the fingers are in the opposite direction)
◆ Long press
◆File Sharing support
File Sharing support was introduced from IOS 3.2. It can be used to develop user data files to iTunes.
9.1 and later versions. Once the program declares that it supports file sharing, the files in ITS/Documents Files directory will be open to users. You can use iTunes to put files in or retrieve
. This feature does not allow your program to share files with other programs on the same device. You need to use clipboard or text interaction to control objects.
(Uidocumentinteractioncontroller.
To enable file sharing support, please:
◆ Add the uifilesharingenabled key to the info. ppst file of the program, and set the value to yes.
◆ Place the file you want to share in the program's documents directory.
◆ When the device is inserted into the user's computer, iTunes displays a file sharing block under the program page of the selected device.
◆ You can add or delete files on the desktop.
Programs that support file sharing must be able to identify files placed in the documents directory and process them correctly. For example, a program should use its own interface to display new files, rather than listing these files in a directory and asking users how to handle these files.
◆Point-to-Point combat service
The game KIT framework introduced from IOS 3.0 provides a Bluetooth-based point-to-point combat function. You can use point-to-point connections to establish communication with nearby devices. This is a feature that many multiplayer games require. Although this is mainly used for games, it can also be used in other types of programs.
◆Standard System View Controller
Many cocoa touch layer frameworks provide a view controller to display standard system interfaces. You should try to use these view controllers to maintain consistent user experience. You should use the View Controller provided by the corresponding framework whenever you need to perform the following operations:
Display and edit contact information
◆ Use the View Controller provided by the address book UI framework.
Create and edit calendar events
◆ Use the View Controller provided by the event kit UI framework.
Write email or Short Message
◆ View Controller provided by message UI framework.
Open or preview the File Content
◆ Use the uidocumentinteractioncontroller class in the uikit framework.
Take a photo or select a photo from your photo library
◆ Use the uiimagepickercontroller class in the uikit framework.
Take a video
◆ Use the uiimagepickercontroller class in the uikit framework.
◆External display support
IOS
Starting from 3.2, external display support was introduced, allowing some iOS devices to connect to external monitors through the supported cables. During connection, the program can display the content on the corresponding screen. Screen information, package
The supported resolutions can all be accessed using interfaces provided by the uikit framework. You can also use this framework to connect a program window to a screen or another screen.
Cocoa touch framework
The following sections describe the cocoa touch layer framework and the services they provide.
Address book UI framework
Address book UI framework
(Addressbookui. Framework) is
The objective-C programming interface is used to display the standard system interface for creating, editing, and selecting existing contacts. This framework allows you to easily display contact information in the program.
Make sure that your program uses the same interface as other programs and maintains the platform consistency.
For more information about the class of the address book UI framework and how to use them, seeIOS Address Book UI framework reference manual
.
Event kit UI framework
From IOS 4.0, the event kit UI framework (eventkitui. Framework) was introduced to provide a View Controller for displaying and editing events.
Game KIT framework
Game is introduced in IOS 3.0.
The KIT framework (gamekit. Framework) supports point-to-point network communication in programs. In particular, this framework supports point-to-point connections and in-game voice calls. Although
These functions are mainly used for multiplayer online games, but can also be used in non-game programs. The network functions provided by this framework are implemented by several simple classes built on bonjour. These classes are abstracted.
Many network details allow developers without network programming experience to easily add network functions to programs.
IAD framework
IOS 4.0 introduces the IAD framework (IAD. Framework) Support Program to display banner advertisements. Advertisements are composed of standard views. you can insert them into your user interface and display them properly. View itself communicates with Apple's advertising service to handle all the work of loading and displaying ad content and responding to clicks.
Map KIT framework
MAP is introduced in IOS 3.0.
The KIT framework (mapkit. Framework) provides a map interface that can be embedded into a program. Based on the behavior of this interface, it provides a scalable map view that can mark custom
Information. You can embed it in the view of the program, program the map attributes, and save the currently displayed map area and user location. You can also define custom tags or use standard tags (pins
To highlight the area on the map and display additional information.
From IOS
Starting from 4.0, this framework adds the ability to drag tags and customize override objects. The drag tag allows you to move a tag that has been placed on a map, program it, or use user behavior. Overwrite object extraction
Allows you to create map tags that are more complex than markup points. You can use the overwriting object to place information on the map, such as the bus route, selection chart, parking area, and weather information (such as radar data ).
Message UI framework
Message is introduced in IOS 3.0.
The UI framework (messageui. framewok) provides the ability to write and query binning messages. Write support contains a view that can be displayed in the program
Controller Interface. You can enter the information you want to send in the interface. You can set the recipient, subject, content, and attachment. You can select the priority of the information. After the selection, the information is
Will wait for sending in the user's sending queue.
For IOS 4.0 and later systems, this framework began to support the view controller used to write short messages. You can use this view controller to create and edit short messages without leaving the program. Like the email writing interface, this interface allows users to select whether to edit before sending.
Uikit framework
Uikit framework
(Uikit. Framework) contains the objective-C programming interfaces for key architectures such as graphics and event-driven programming in IOS. Every program in IOS uses this framework to implement the following core features:
◆ Application Management
◆ User Interface Management
◆ Graphics and window support
◆ Multi-task support
◆ Support for touch processing and action-based events
◆ Display objects of standard system views and controls
◆ Support for text and web content
◆ Cutting, copying, and pasting support
◆ UI animation support
◆ Interact with other programs in the system in URL Mode
◆ Support for Apple push notifications
◆ Easy-to-use support for persons with disabilities
◆ Reservation and sending of local notifications
◆ Create PDF
◆ Supports custom input views with behaviors similar to system keyboards
◆ Supports creating text views customized for interaction with system keyboards
In addition to supporting the basic code of the program, uikit also supports some device features, such:
◆ Accelerometer Data
◆ Built-in camera (if any)
◆ User's photo library
◆ Device name and Model Information
◆ Battery status information
◆ Proximity sensor information
◆ Headset Line Control Information