BT
x Your opinion matters! Please fill in the InfoQ Survey about your reading habits!

A Look at MonoTouch.Dialog

by Jonathan Allen on Feb 15, 2012 |

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.

Hello stranger!

You need to Register an InfoQ account or or login to post comments. But there's so much more behind being registered.

Get the most out of the InfoQ experience.

Tell us what you think

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread
Community comments

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Discuss

Educational Content

General Feedback
Bugs
Advertising
Editorial
InfoQ.com and all content copyright © 2006-2014 C4Media Inc. InfoQ.com hosted at Contegix, the best ISP we've ever worked with.
Privacy policy
BT