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.

1

1 Answer 1

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.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.