O'Reilly logo

Appcelerator Titanium Smartphone App Development Cookbook - Second Edition by Jason Kneen

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Creating a "Pull to Refresh" mechanism in iOS

What if you want the user to be able to refresh the feed data in your table? You could create a regular button, or possibly check for new data after arbitrary time intervals. Alternatively, you can implement a cool "pull and refresh" mechanism, which has become the de facto standard refresh method in iOS.

In this recipe for our recipe finder app, we'll implement this very type of refresh mechanism for our recipes' feed using the built-in, native refresh control.

How to do it...

Open your recipes.js file and type the following under the creation of tblRecipes:

if (Ti.Platform.name === "iPhone OS") { var p2r = Ti.UI.createRefreshControl({ tintColor: '#000' }); tblRecipes.refreshControl = p2r; p2r.addEventListener('refreshstart', ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required