Our first blog post of 2010 presents a tool that we’ve been using internally and that might be useful for other people.
As you might have experienced, prototyping applications in Interface Builder is fine as long as you don’t deal that much with UITableViewController instances. Prototyping user interfaces with tables and navigation is not as easy as drag-and-dropping some components, and you usually have to implement a small UITableViewController subclass from scratch yourself, including some kind of navigation logic.
Enter EasyTableView, a set of classes inheriting from UINavigationController and UITableViewController, ready to use in your own projects, to quickly simulate interfaces using navigation and tables. I’ve been using this code in several prototypes, and it allows me to quickly craft navigation-based applications loading several different tables. The AKOEasyTableViewControllerDelegate protocol allows other classes to be notified of taps on cells or on accessory buttons.
The code is available, as usual, in Github with a liberal BSD license.
The code snippets below show how to use the classes:
NSArray *data = [NSArray arrayWithObjects:@"first", @"second", @"third", nil]; AKOEasyTableViewController *controller = nil; controller = [[AKOEasyTableViewController alloc] initWithStyle:UITableViewStylePlain]; controller.title = @"Easy Table View"; controller.delegate = self; // AKOEasyTableViewControllerDelegate... controller.dataSource = data; controller.autoDeselect = YES; controller.accessoryType = UITableViewCellAccessoryDisclosureIndicator; _navigationController = [[AKOEasyNavigationController alloc] initWithRootViewController:controller]; _navigationController.dataSequenceFileName = @"Sequence";
With the code above, the freshly created AKOEasyNavigationController will load the file “Sequence.plist”, which itself references other plist files in your project.
Data can be loaded in code (as NSArray or NSDictionary instances) or using external plist files, through the dataSourceFileName property of the AKOEasyTableViewController class. The formats of the data in the plist files is the simplest you could imagine:
< ?xml version="1.0" encoding="UTF-8"?> < !DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
Roger Federer Rafael Nadal Novak Djokovic Andy Murray Juan Martin Del Potro Andy Roddick Nicolay Davydenko Fernando Verdasco Robin Soderling Jo-Wilfred Tsonga Fernando González Radek Stepanek Gael Monfils Marin Cilic Gilles Simon
The plist files can also be NSDictionary instances, with a “title” NSString key, and a “values” key of type NSArray; in this case, the controller is shown with several different groups. AKOEasyNavigationController requires the AKOEasyTableViewController class, but you can use this last one independently as well.
Feel free to clone the project, use it in your own projects and send me any feedback you might have. Enjoy!
- None Found