学习笔记3

来源:互联网 发布:灰度图像锐化算法 编辑:程序博客网 时间:2024/06/06 02:19

UIImage

imageNamed 的接口

name

The name of the file. If this is the first time the image is being loaded, the method looks for an image with the specified name in the application’s main bundle.

Return Value

The image object for thespecified file, or nil if the method could not find the specified image.

 

Discussion

This method looks in thesystem caches for an image object with the specified name and returns thatobject if it exists. If a matching image object is not already in the cache,this method locates and loads the image data from disk or asset catalog, andthen returns the resulting object.

 

 

View and Window Architecture

EveryiOS application needs at least one window—an instance of the UIWindow class—and some may include morethan one window. A window object has several responsibilities:

·      It contains your application’s visible content.

·      It plays a key role in the delivery of touch events to your viewsand other application objects.

·      It works with your application’s view controllers to facilitateorientation changes.

 

 The role of objects inan iOS app

Object

Description

UIApplicationobject

The UIApplication object manages the event loop and other high-level app behaviors. It also reports key app transitions and some special events (such as incoming push notifications) to its delegate, which is a custom object you define. Use the UIApplicationobject as is—that is, without subclassing.

App delegateobject

The app delegate is the heart of your custom code. This object works in tandem with the UIApplication object to handle app initialization, state transitions, and many high-level app events. This object is also the only one guaranteed to be present in every app, so it is often used to set up the app’s initial data structures.

Documents and data model objects

Data model objects store your app’s content and are specific to your app. For example, a banking app might store a database containing financial transactions, whereas a painting app might store an image object or even the sequence of drawing commands that led to the creation of that image. (In the latter case, an image object is still a data object because it is just a container for the image data.)

Apps can also use document objects (custom subclasses of UIDocument) to manage some or all of their data model objects. Document objects are not required but offer a convenient way to group data that belongs in a single file or file package. For more information about documents, see Document-Based App Programming Guide for iOS.

View controller objects

View controller objects manage the presentation of your app’s content on screen. A view controller manages a single view and its collection of subviews. When presented, the view controller makes its views visible by installing them in the app’s window.

The UIViewController class is the base class for all view controller objects. It provides default functionality for loading views, presenting them, rotating them in response to device rotations, and several other standard system behaviors. UIKit and other frameworks define additional view controller classes to implement standard system interfaces such as the image picker, tab bar interface, and navigation interface.

For detailed information about how to use view controllers, see View Controller Programming Guide for iOS.

UIWindowobject

UIWindow object coordinates the presentation of one or more views on a screen. Most apps have only one window, which presents content on the main screen, but apps may have an additional window for content displayed on an external display.

To change the content of your app, you use a view controller to change the views displayed in the corresponding window. You never replace the window itself.

In addition to hosting views, windows work with the UIApplication object to deliver events to your views and view controllers.

View objects,control objects, and layer objects

Views and controls provide the visual representation of your app’s content. A view is an object that draws content in a designated rectangular area and responds to events within that area. Controls are a specialized type of view responsible for implementing familiar interface objects such as buttons, text fields, and toggle switches.

The UIKit framework provides standard views for presenting many different types of content. You can also define your own custom views by subclassing UIView (or its descendants) directly.

In addition to incorporating views and controls, apps can also incorporate Core Animation layers into their view and control hierarchies. Layer objects are actually data objects that represent visual content. Views use layer objects intensively behind the scenes to render their content. You can also add custom layer objects to your interface to implement complex animations and other types of sophisticated visual effects.

 

TheMain Run Loop

An app’s main run loop processesall user-related events. The UIApplication object sets up the main run loop at launch time and uses it toprocess events and handle updates to view-based interfaces. As the namesuggests, the main run loop executes on the app’smain thread. This behavior ensures that user-related events areprocessed serially in the order in which they were received.

 

0 0
原创粉丝点击