Posted by AVAI Mobile Developer on Tue, Nov 17, 2009 @ 11:25 PM
When developing mobile applications, user interface design is one of the most crucial elements that you need to worry about. Users are already restricted to a tiny keyboard and 3.5" screen, so they start out having less patience than they would for say, a desktop application. With that in mind, whenever an application has to perform a task that takes more than half a second, such as downloading data, or doing a lot of computation, the user needs to be notified with an activity indicator view or progress view that the app is still working, and has not simply frozen.
So how do we add an activity indicator to notify the user when the application is working? You might assume that you can add a UIActivityIndicator in Interface Builder, link it up with an outlet in your view controller, and just call the startAnimating and stopAnimating methods before and after the code for downloading images. With this method, the view will not actually be loaded on the screen until after the images are downloaded, so you will never even see the activity indicator. This is because the downloading of images is occurring in the main thread, which also happens to be the one used for UI updates. So, while fetching images, the UI thread is blocked from doing updates, so your activity indicator doesn't appear until it's done.
The solution is to download images in another thread, and call back the main thread when you're done. This can be done with the performSelectorInBackground and performSelectorOnMainThread methods from the NSObject class. The code below outlines the method just described.
- (void)viewDidLoad
{
[self.activityIndicator startAnimating];
[NSThread detachNewThreadSelector:@selector(downloadImages) toTarget:self withObject:nil];
[super viewDidLoad];
}
-(void) downloadImages
{
//Download images here
//Once the download is complete, go load the downloaded images into the table.
[self performSelectorOnMainThread:@selector(loadTable) withObject:nil waitUntilDone:NO];
}
-(void) loadTable
{
[self.activityIndicator stopAnimating];
[self.tableView reloadData];
}
Richard
Posted by Eric Mills on Wed, Oct 28, 2009 @ 10:14 AM
Want to see a company that gets social media? Look no further than Malibu Boats. They make boats, so you might be surprised at how they are using twitter, their blog, their youtube channel, and delicious to interact with their customers.
Last week, the Malibu Boats iPhone App was approved and I really believe this is a beautiful piece of mobile marketing. Malibu managed to provide value to prospects, existing customers, and their dealers, which ultimately benefits their entire ecosystem. Download the app and you'll see what I am talking about.
Ask yourself this question: as a product manufacturer, what is the best thing you can do for your dealers? The answer: bring them business. This is exactly what the Malibu Boats iPhone App does. It uses the GPS signal in the phone to locate the nearest dealer. Users can contact that dealer through phone or email and get driving directions with just a few taps. Users can also request pricing information from that dealership by filling out a simple form. These pricing requests are routed through Malibu's lead management system and distributed to the appropriate dealer. In addition, users can contact Malibu Boats and request a brochure, tour request, or subscribe to their ENews.
Malibu has hit the sweet spot with this iPhone app. Users get updated news, videos, blog posts, and an easy way to contact their closest dealer and the manufacturer. Dealers get local leads, and Malibu gets all the accolades for reaching their customers on a mobile platform.