Assignment #4 Task #8

Please note, this blog entry is from a previous course. You might want to check out the current one.

Whenever a photo’s image appears on screen, it should initially be zoomed to show as much of the photo as possible with no extra, unused space. It is not necessary to continue to do this as the user rotates the device or zooms in and out on the photo by pinching.

To solve that we check what the zoom scales would be when we would display the complete width or height of the image, and set the actual scale to the larger value:

    double wScale = self.scrollView.bounds.size.width / image.size.width;
    double hScale = self.scrollView.bounds.size.height / image.size.height;
    if (wScale > hScale) self.scrollView.zoomScale = wScale;
    else self.scrollView.zoomScale = hScale;

The complete code for this task is available at github.

Facebooktwittergoogle_plusredditpinterestlinkedintumblrmailFacebooktwittergoogle_plusredditpinterestlinkedintumblrmail

Flattr this!

Leave a Reply

Your email address will not be published. Required fields are marked *