What is the best way to implement scrolling between views in OS X?

What is the best way to implement scrolling between views in OS X? These views are initialized from nibs with their view controllers, and they are the same type of class. To give some background, each view displays the corresponding data for the current date.

I would like to create a function that loads data for the next (or previous) date. I could just load the data into the current view, but can I do this with an animation similar to scrolling between spaces in OS X? I assume that I will have to initialize a new view, load the data there, and then initiate the transition to a new view.

I worry that the performance of creating all these new views will be pretty poor. Here are a few options that I considered to solve this problem:

  • Create an NSDate Dictionary for MYViewController. Download and save each view from this hash map, but it can take a lot of memory.
  • Create a doubly linked list of MYViewController and load / save sequentially viewed views. This can potentially take up a lot of memory, and if the user goes to the date, the caching will simply be deleted.

Any thoughts? If there is a way to download data in its current form, I feel this is the best option.

Thanks!

+7
source share
2 answers

Have you just considered using UIScrollView and having one UIViewController to control all kinds? Here's a good tutorial from Ray Wenderlich's website on UIScrollView :

http://www.raywenderlich.com/10518/how-to-use-uiscrollview-to-scroll-and-zoom-content

Alternatively, did you consider perhaps using a horizontal table view? Here's a third-party implementation that I saw is recommended for other SO posts:

https://github.com/TheVole/HorizontalTable

Edit

Sorry, I quickly read your question and suggested that this is for iOS ...

I think you could find something like an NSCollectionView , perhaps (not sure if this will support off-screen views in horizontal order or not ...?)

Here are the docs on it:

https://developer.apple.com/library/mac/#documentation/Cocoa/Reference/NSCollectionView_Class/Introduction/Introduction.html

Here is a tutorial on this:

http://andrehoffmann.wordpress.com/2009/08/29/nscollectionview-tutorial-for-dummies-xcode-3-1-3/

(Honestly, I have not done a lot of OSX development, so a little from my area of ​​expertise here ... I wish you good luck!)

0
source

Cocoa watching a transient animation is not an easy thing. This is much more complex coding than managing a view controller.

You need to decide how to achieve the desired effects. Take a look at this document and other links: Animation Programming Guide for Cocoa

I did a similar job a few months ago. My final permission was to use a single view and animate animations with only graphic APIs (graphic image), because it was simpler than Core Animation.

0
source

All Articles