Sunday, 18 July 2010

Multiview Applications

Real Power of iPhone platform emerges when you can switch out views based on user input.
Simplest example of a multiview application is a utility app. A utility view focusses primarily on a single view but offers a second view that can be used to provide more detail than the primary view.
Several tab bar apps that ship with the iPhone.

A tab bar is used for selecting one and only one option from among two or more. A toolbar can hold buttons and certain other controls, but those items are not mutually exclusive.

Nearly all multiview applications use the same basic pattern. The nib file is a key player.
The root controller is the primary view controller for the application and as such is the view that specifies whether it is ok to automatically rotate to a new orientation, though the root controller can pass responsibility for things like that to the current active controller.

In multiview apps most of the screen will be taken up by a content view and each content view will have its own controller with its own outlets and actions.
In a tab bar application, for example tapping on the tab bar will go to the tab bar controller, but taps anywhere else on the screen will go to the controller that corresponds to the content view currently being displayed.

Each content view generally consists of up to three pieces: the view controller, the nib and a subclass of UIView.
Content view will always usually have an associated view controller, will usually have a nib and will sometimes have a subclass UIView.

One of the most daunting aspect of creating a multiview app from scratch is that several interconnected objects have to be created.
Toolbar buttons aren't like iPhone controls. They support only a single target action and the trigger that action only at one well defined moment, the equivelant of a touch up inside event on other iPhone controls.

Lazy loading is when the view is loaded the first time it is needed and is a standard way of keeping memory overhead down.
Lazy loading is a key component of resource management on the iPhone and should be implemented anywhere possible.

In a complex multiview application, being responsible and flushing unused objects from memory can be the difference between an application that works well and one that crashes periodically because it ran out of memory,

No comments:

Post a Comment

Search This Blog