Wednesday, October 19, 2011

Custom Appearance for UIKit Controls

Custom Appearance for UIKit Controls You can now customize the appearance of many UIKit views and controls to give your application a unique look and feel. For example, you might use these customizations to make the standard system controls match the branding for the rest of your application. UIKit supports the following customizations: You can set the tint color, background image, and title position properties (among other) on a wide variety of objects, including toolbars, navigation bars, search bars, buttons, sliders, and some other controls. You can set attributes of some objects directly, or you can set the default attributes to use for a class using an appearance proxy.An appearance proxy is an object you use to modify the default appearance of visual objects such as views and bar items. Classes that adopt the UIAppearance protocol support the use of an appearance proxy. To modify the default appearance of such a class, retrieve its proxy object using the appearance class method and call the returned object’s methods to set new default values. A proxy object implements those methods and properties from its proxied class that are tagged with the UI_APPEARANCE_SELECTOR macro. For example, you can use a proxy object to change the default tint color (through the progressTintColor or trackTintColor properties) of the UIProgressViewclass.If you want to set a different default appearance based on how a given object is used in your application, you can do so using the proxy object returned by the appearanceWhenContainedIn:method instead. For example, you use this proxy object to set specific default values for a button only when it is contained inside a navigation bar.Any changes you make with a proxy object are applied, at view layout time, to all instances of the class that exist or that are subsequently created. However, you can still override the proxy defaults later using the methods and properties of a given instance. Container View Controller Support The UIViewController class now allows you to define your own custom container view controllers and present content in new and interesting ways. Examples of existing container view controllers include UINavigationController, UITabBarController, andUISplitViewController. These view controllers mix custom content with content provided by one or more separate view controller objects to create a unique presentation for application content. Container view controllers act as a parent for their contained view controllers, forwarding important messages about rotations and other relevant events to their children. Settings Applications that deliver custom preferences can now use a new radio group element. This element is similar to the multivalue element for selecting one item from a list of choices. The difference is that the radio group element displays its choices inline with your preferences instead of on a separate page.

Data Protection Improvements

Introduced in iOS 4.0, data protection lets you store application and user data files on disk in an encrypted format so that they can be accessed only when a user’s device is unlocked. In iOS 5.0, you now have more flexibility regarding when your application can access protected files. Using the NSFileProtectionCompleteUnlessOpen option, your application can access a file while the device is unlocked and, if you keep the file open, continue to access that file after the user locks the device. Using the NSFileProtectionCompleteUntilFirstUserAuthentication option, your application cannot access the file while the device is booting or until the user unlocks the device. After the user unlocks the device for the first time, you can access the file even if the user subsequently locks the device again. You should protect files as soon as possible after creating them.

Application Design-Level Improvements

The following sections describe new capabilities that you can incorporate into the model, view, and controller layers of your application. Document Support Cocoa Touch now includes a UIDocument class for managing the data associated with user documents. If you are implementing a document-based application, this class reduces the amount of work you must do to manage your document data. In addition to providing a container for all of your document-related data, the UIDocument class provides built-in support for a number of features: Asynchronous reading and writing of data on a background queue, allowing your application to remain responsive to users while reading and writing operations occur. Support for coordinated reading and writing of documents, which is required for documents in iCloud storage. Safe saving of document data by writing data first to a temporary file and then replacing the current document file with it. Support for resolving conflicts between different versions of your document if a conflict occurs. Automatic saving of document data at opportune moments. Support for flat file and package file representations on disk. For applications that use Core Data to manage their content, there is also a UIManagedDocument subclass to manage interactions with documents in the database. If you are implementing an application that supports iCloud storage, the use of document objects makes the job of storing files in iCloud much easier. Document objects are file presenters and handle many of iCloud-related notifications that you might otherwise have to handle yourself.

Generic Security Services Framework

The Generic Security Services framework (GSS.framework) provides a standard set of security-related services to iOS applications. The basic interfaces of this framework are specified in IETF RFC 2743 and RFC 4401. In addition to offering the standard interfaces, iOS includes some additions for managing credentials that are not specified by the standard but that are required by many applications.

Accounts Framework

The Accounts framework (Accounts.framework) provides a single sign-on model for certain user accounts. Single sign-on improves the user experience, because applications no longer need to prompt a user separately for login information related to an account. It also simplifies the development model for you by managing the account authorization process for your application. In iOS 5.0, applications can use this framework in conjunction with the Twitter framework to access a user’s Twitter account.

Followers