Zooming to a point in UIScrollView

Saturday, January 14th, 2012

If there’s one piece of functionality that has become basically boilerplate on iOS, it’s the concept of double-tapping a zoomable UIScrollView to quickly zoom in on a given point. When I was writing the code for displaying pages in iComics, I assumed that this would be a really simple thing to do. I mean, surely all you’d need is a UITapGestureRecognizer attached to a UIScrollView that passes the location of any double-taps to the scroll view… right?

Nope. XD

Turns out that although there is a UIScrollView method called ‘zoomToRect‘ (which lets you zoom to a specific CGRect region of a UIScrollView), out-of-the-box, there is no official way to procedurally zoom into a specific CGPoint. This actually surprised me greatly since I would have thought it would be a standard part of UIKit.

In any case, I did a bit of searching around on Google, looking for some code that would let me do this easily. I found a few bits of code here and there, however they were written in such a way that unless the minimum and maximum scales of the scroll view were set up in a specific way (Uh, which in iComics’ case, they weren’t), the zooming wouldn’t work properly at all.

So, cutting to the chase, I decided to just roll my own category for UIScrollView to add that functionality to it. All it does is take a CGPoint (relative to the bounds of the scroll view itself) and a scale, and translates those to a CGRect that can then be passed to UIScrollView’s drawToRect method. :)

(more…)

Introducing iComics!

Friday, January 13th, 2012

 It’s the final day of my holidays today, and I’ve been silently beavering away on a little project of mine. As with all of my projects, I usually keep them absolutely off the internet until I’ve proven that they actually are viable, and I’m not just blowing smoke. XD

One of my reasons (if not, the main reason) for me buying an iPad was so that I would be able to read digital copies of my books, without needing to lug around their paper counterparts. In terms of being able to read eBooks as ePubs or PDFs, my iPad experience has been perfected thanks to the collective efforts of iBooks and GoodReader.

Unfortunately, up until now, when it comes to reading digital comic books on iPad, while there’s a nice selection of third-party comic readers available, for many varying reasons, I haven’t found one that I’ve been truly content with. Whether it be the way page turning is handled, or even getting the comics onto the device, I haven’t found one I’m happy to stick with.

So with that in mind, I would like to announce my next iOS app project, and I’m calling it iComics. :D

(more…)