Thursday, October 23, 2008

Scroll Views

I've been realizing over the last couple of days that we missed covering something in the book that we should have: UIScrollView. Now that I've spent a few days fighting them, I must admit that I'm glad I missed it. These things are complex and not as well documented as they should be. I've got my app working with hit testing inside of a scroll view, and without jaggies, but my performance isn't good. Here's the thing:

UIScrollView ALWAYS starts at a zoom of 1.0. You can't change this. If you do, it will just cause it to act funny the first time the user touches the screen (please, if I'm wrong on this, correct me). But, if you zoom in on a view, it gets all pixelated and blocky unless you change your content view's (and/or subview's) backing layer to a CATiledLayer. Doing that kills performance on my first generation iPhone. I haven't tested it yet on my second generation iPod Touch, but I suspect it will only be a little bit better.

But, here's the thing. If I change the size so that I start zoomed in... so that the content view is the size of the zoomed view and don't use CATiledLayer, it works beautifully, scrolls fast, no skips, etc. But, I don't want the user to have to start zoomed way in. The program won't be intuitive if I do that.

A related problem is that I can't get the double-tap zoom and unzoom working. In an old edition of the iPhone Programming guide, there was sample code that supposedly showed how to do that, but I've tried it, and many, many variants of it, and never have gotten it to work right. There might be a reason why that code sample is no longer in the programming guide.

Anybody out there gotten this working?

No comments:

Post a Comment