1

What I do now:

I have a UITableView that displays results from a search query, when I touch a result in the TableView it loads a subview that displays details of that result. I can swipe across that subview to switch between results like next and previous. All it does is change out the displayed data but it uses the same view

What I want to do:

I want it to show an animation when swiping between results, similar to the photos app, however since the number of results can be quite large I seem to be having issues figuring out a simple way to switch views when swiping without loading a new view for each result to start with.

Does anyone know of an easy way to do this? Perhaps Apple has already made this easy and I am just unaware.

Thanks in advance.

Weston
  • 1,481
  • 1
  • 11
  • 31
  • I just posted an answer (with code) in the similar question [here][1] [1]: http://stackoverflow.com/questions/6244776/iphone-navigate-to-previous-next-viewcontroller/11617283#11617283 – software evolved Jul 23 '12 at 17:18

1 Answers1

1

Instead of instantiating a new view for each result, you could have an array with a few views (3 for example), and reuse them, kinda like the UITableView. When you swipe, you retrieve from your array a view that is not visible on the screen, replace its content, and display it. I guess at the end of your animation, one view will get out of the screen, so it will be available for reuse later on.

A second idea, which is a little more complex and tricky to code, is to use a UITableView as your subview, rotate it by 90 degrees (so it scrolls horizontally), and rotate all the views you put in its cells by -90 degrees. Then you'll benefit from the tableview's reuse mechanism.

Olivier
  • 387
  • 1
  • 9