O'Reilly logo

Learning iOS Development: A Hands-on Guide to the Fundamentals of iOS Programming by Erica Sadun, Rod Strougo, Maurice Sharp

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

What Car Is This?

The final thing you need to do with the car image scene is to correctly set the car number. With paging enabled, you know how much width each car takes. You also know the location of the scroll view in the content. To find the number (not the index) of the car, find the number of page widths.

You need to add the methods in Listing 6-5 above viewDidLoad:. The methods update the label and find the current car index. The car index is 0-based, so add 1 before displaying.

Listing 6-5 Updating the Label Using the Index of the Current Car Image

- (void) updateCarNumberLabel {     NSInteger carIndex = [self carIndexForPoint:self.scrollView.contentOffset];     NSString *newText = [NSString stringWithFormat:@"Car ...

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