BT

Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ

Topics

Choose your language

InfoQ Homepage News A Look at MonoTouch.Dialog

A Look at MonoTouch.Dialog

This item in japanese

MonoTouch.Dialog is a UI development toolkit designed to dramatically reduce the amount of boilerplate code needed to create application screens. Through the creative use of attributes, screens are dynamically built from class definitions. Alternately they can be programmatically created or loaded from a JSON document.

MonoTouch.Dialog or MT.D consists of two libraries. A low-level Elements API allows developers to define a hierarchal tree of elements that represent screens and their components. This allows for dynamic UI construction (think server-generated forms). This is also the layer that supports loading JSON-based screen definitions.

The high-level Reflection API, also known as the Binding API, uses annotated classes to declaratively construct user interfaces. These classes can represent the model objects themselves or be coded as wrappers around them.

A MT.D screen is composed of four basic parts. The DialogViewController replaces iOS’s normal TableViewController and can be used the same way. The next piece is the RootElement, a renderless container that holds Sections and Elements. A section is a logical grouping of controls while an element represents a single data-bound control.

When using the Reflection API, sections and elements are laid out in the same order as they are declared in the source code. This means it is essential that you disable any code cleanup tools that can reorder the properties and methods in a source file.

In order to go beyond the basic controls, advanced developers will want to learn how to work with the OwnerDrawnElement and Element base classed. OwnerDrawnElement allows developers to define their own look and feel by directly manipulating a CGContext while Element gives them full control.

MonoTouch.Dialog specifically avoids the topic of data validation. They recommend that validation be manually implemented and triggered when the user presses a “next” or “done” button.

Rate this Article

Adoption
Style

BT