O'Reilly logo

The Core iOS Developer’s Cookbook, Fifth Edition by Rich Wardwell, Erica Sadun

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

Adding Efficiency

Recipe 2–3 stores a previous value for the slider to minimize the overall computational burden on iOS. It updates the thumb with a new custom image when the slider has changed by at least 0.1, or 10% in value. You can omit this check, if you want, and run the recipe with full live updating. This provided reasonably fast updates even on a first-generation iPod touch unit. On recent iPhones and iPads, it has no performance issues at all.

This recipe also avoids any issues at the ends of the slider—namely when the thumb gets caught at 0.9 and won’t update properly to 1.0. In this recipe, a hard-coded workaround for values above 0.98 handles that particular situation by forcing updates.

Recipe 2-3 Building Dynamic Slider Thumbs ...

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